Browse Source

Fix clang-tidy warning inside String class

Patrick-Christopher Mattulat 1 year ago
parent
commit
177b6e9e5d

+ 1 - 6
include/ls-std/boxing/String.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-14
- * Changed:         2023-02-08
+ * Changed:         2023-02-22
  *
  * */
 
@@ -28,11 +28,6 @@ namespace ls::std::boxing
       explicit String(::std::string _value);
       ~String() override;
 
-      // conversion operator
-
-      operator const char *() const;  // do not make explicit!
-      operator ::std::string() const; // do not make explicit!
-
       // assignment operators
 
       ls::std::boxing::String &operator=(::std::string _value);

+ 1 - 11
source/ls-std/boxing/String.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-08-14
- * Changed:         2023-02-07
+ * Changed:         2023-02-22
  *
  * */
 
@@ -18,16 +18,6 @@ ls::std::boxing::String::String(::std::string _value) : ls::std::core::Class("St
 
 ls::std::boxing::String::~String() = default;
 
-ls::std::boxing::String::operator const char *() const
-{
-  return this->value.c_str();
-}
-
-ls::std::boxing::String::operator ::std::string() const
-{
-  return this->value;
-}
-
 ls::std::boxing::String &ls::std::boxing::String::operator=(::std::string _value)
 {
   this->value = ::std::move(_value);

+ 3 - 3
test/cases/boxing/StringTest.cpp

@@ -208,7 +208,7 @@ namespace
     text = "abcdef";
 
     ASSERT_STREQ("fedcba", text.reverse().c_str());
-    ASSERT_STREQ("abcdef", text); // verify, that original string didn't change
+    ASSERT_STREQ("abcdef", text.toString().c_str()); // verify, that original string didn't change
   }
 
   TEST_F(StringTest, startsWith)
@@ -233,7 +233,7 @@ namespace
     text = "aBCdeFgHIJKLmn";
 
     ASSERT_STREQ("abcdefghijklmn", text.toLowerCase().c_str());
-    ASSERT_STREQ("aBCdeFgHIJKLmn", text); // verify, that original String didn't change
+    ASSERT_STREQ("aBCdeFgHIJKLmn", text.toString().c_str()); // verify, that original String didn't change
   }
 
   TEST_F(StringTest, toUpperCase)
@@ -242,6 +242,6 @@ namespace
     text = "aBCdeFgHIJKLmn";
 
     ASSERT_STREQ("ABCDEFGHIJKLMN", text.toUpperCase().c_str());
-    ASSERT_STREQ("aBCdeFgHIJKLmn", text); // verify, that original String didn't change
+    ASSERT_STREQ("aBCdeFgHIJKLmn", text.toString().c_str()); // verify, that original String didn't change
   }
 }