Browse Source

Extend generic append by const char array cast

Kajetan Johannes Hammerle 2 weeks ago
parent
commit
839ad77fc8
4 changed files with 7 additions and 6 deletions
  1. 2 0
      include/core/utils/ArrayString.hpp
  2. BIN
      test/.Test.hpp.swo
  3. 2 3
      test/Test.cpp
  4. 3 3
      test/Test.hpp

+ 2 - 0
include/core/utils/ArrayString.hpp

@@ -12,6 +12,8 @@ namespace Core {
         CError genericAppend(String& s, const T& t) {
             if constexpr(requires { t.toString(s); }) {
                 return t.toString(s);
+            } else if constexpr(requires { static_cast<const char*>(t); }) {
+                return s.append(static_cast<const char*>(t));
             } else {
                 char buffer[64];
                 CORE_RETURN_ERROR(toString(t, buffer, CORE_SIZE(buffer)));

BIN
test/.Test.hpp.swo


+ 2 - 3
test/Test.cpp

@@ -20,9 +20,8 @@ void Core::Test::finalize() {
         const char* color = e.value.successTests == e.value.tests
                                 ? Logger::COLOR_GREEN
                                 : Logger::COLOR_RED;
-        Logger::log(color, "# - # / # tests succeeded",
-                    static_cast<const char*>(e.getKey()), e.value.successTests,
-                    e.value.tests);
+        Logger::log(color, "# - # / # tests succeeded", e.getKey(),
+                    e.value.successTests, e.value.tests);
     }
     Internal::results.clear();
 }

+ 3 - 3
test/Test.hpp

@@ -34,9 +34,9 @@ namespace Core::Test {
                 result->successTests++;
                 return true;
             }
-            Core::Logger::log(
-                Core::Logger::COLOR_RED, "#:# - expected '#' got '#'",
-                static_cast<const char*>(fileName), line, wanted, actual);
+            Core::Logger::log(Core::Logger::COLOR_RED,
+                              "#:# - expected '#' got '#'", fileName, line,
+                              wanted, actual);
             return false;
         }