commit a352d0189aa744bda3ab7a760b6fece799400a0a
parent 6a4656904d6e20f96617045e57d9d2357bc6ed50
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date: Thu, 29 Apr 2021 16:15:36 +0000
Add test for cometa::type_name
Diffstat:
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/include/kfr/cometa/ctti.hpp b/include/kfr/cometa/ctti.hpp
@@ -27,13 +27,16 @@ constexpr inline type_id_t typeident_impl() CMT_NOEXCEPT
return type_id_t(pconstvoid(&typeident_impl<T>));
}
-#ifdef CMT_COMPILER_CLANG
+#if defined CMT_COMPILER_CLANG && CMT_COMPILER_MSVC
constexpr size_t typename_prefix = sizeof("auto __cdecl cometa::ctype_name(void) [T = ") - 1;
constexpr size_t typename_postfix = sizeof("]") - 1;
-#elif CMT_COMPILER_MSVC
+#elif defined CMT_COMPILER_CLANG
+constexpr size_t typename_prefix = sizeof("auto cometa::ctype_name() [T = ") - 1;
+constexpr size_t typename_postfix = sizeof("]") - 1;
+#elif defined CMT_COMPILER_MSVC
constexpr size_t typename_prefix = sizeof("auto __cdecl cometa::ctype_name<") - 1;
constexpr size_t typename_postfix = sizeof(">(void) noexcept") - 1;
-#else
+#else // GCC
constexpr size_t typename_prefix = sizeof("constexpr auto cometa::ctype_name() [with T = ") - 1;
constexpr size_t typename_postfix = sizeof("]") - 1;
#endif
diff --git a/tests/base_test.cpp b/tests/base_test.cpp
@@ -105,6 +105,11 @@ TEST(test_gen_expj)
// In most cases error is much lower (less than 0.00001)
}
+TEST(ctti)
+{
+ CHECK(cometa::type_name<float>() == std::string("float"));
+}
+
} // namespace CMT_ARCH_NAME
#ifndef KFR_NO_MAIN