Michele Caini 6 лет назад
Родитель
Сommit
df13d993f7
2 измененных файлов с 27 добавлено и 0 удалено
  1. 2 0
      TODO
  2. 25 0
      test/entt/core/type_traits.cpp

+ 2 - 0
TODO

@@ -34,3 +34,5 @@
 * use [[nodiscard]] consistently for safety purposes
 * static reflection, hint: template<> meta_type_t<Type>: meta_descriptor<name, func..., props..., etc...>
 * null support for entt::component
+* make macros require a trailing ;
+* named_type_traits<Type>::value -> named_type_traits_v<Type>

+ 25 - 0
test/entt/core/type_traits.cpp

@@ -1,6 +1,15 @@
 #include <gtest/gtest.h>
 #include <entt/core/type_traits.hpp>
 
+ENTT_NAMED_TYPE(int);
+ENTT_NAMED_STRUCT(named_struct, {})
+ENTT_NAMED_CLASS(named_class, {})
+
+TEST(Choice, Functionalities) {
+    ASSERT_TRUE((std::is_base_of_v<entt::choice_t<0>, entt::choice_t<1>>));
+    ASSERT_FALSE((std::is_base_of_v<entt::choice_t<1>, entt::choice_t<0>>));
+}
+
 TEST(TypeList, Functionalities) {
     using type = entt::type_list<int, char>;
     using other = entt::type_list<double>;
@@ -12,3 +21,19 @@ TEST(TypeList, Functionalities) {
     ASSERT_TRUE((std::is_same_v<entt::type_list_cat_t<type, type>, entt::type_list<int, char, int, char>>));
     ASSERT_TRUE((std::is_same_v<entt::type_list_unique_t<entt::type_list_cat_t<type, type>>, entt::type_list<int, char>>));
 }
+
+TEST(IsEqualityComparable, Functionalities) {
+    ASSERT_TRUE(entt::is_equality_comparable_v<int>);
+    ASSERT_FALSE(entt::is_equality_comparable_v<void>);
+}
+
+TEST(NamedTypes, Functionalities) {
+    ASSERT_TRUE(entt::is_named_type_v<int>);
+    ASSERT_TRUE(entt::is_named_type_v<named_struct>);
+    ASSERT_TRUE(entt::is_named_type_v<named_class>);
+    ASSERT_FALSE(entt::is_named_type_v<char>);
+
+    ASSERT_EQ(entt::named_type_traits_t<int>::value, "int"_hs);
+    ASSERT_EQ(entt::named_type_traits_t<named_struct>::value, "named_struct"_hs);
+    ASSERT_EQ(entt::named_type_traits_t<named_class>::value, "named_class"_hs);
+}