Procházet zdrojové kódy

test: use gtest typed test suite for enums

Michele Caini před 4 roky
rodič
revize
84445aa28b
1 změnil soubory, kde provedl 35 přidání a 31 odebrání
  1. 35 31
      test/entt/core/enum.cpp

+ 35 - 31
test/entt/core/enum.cpp

@@ -19,48 +19,52 @@ template<>
 struct entt::enum_as_bitmask<registered>
     : std::true_type {};
 
-TEST(Enum, Functionalities) {
-    auto test = [](auto identity) {
-        using enum_type = typename decltype(identity)::type;
+template<typename Type>
+struct Enum: testing::Test {
+    using type = Type;
+};
+
+using EnumTypes = ::testing::Types<detected, registered>;
+
+TYPED_TEST_SUITE(Enum, EnumTypes);
 
-        ASSERT_TRUE(!!((enum_type::foo | enum_type::bar) & enum_type::foo));
-        ASSERT_TRUE(!!((enum_type::foo | enum_type::bar) & enum_type::bar));
-        ASSERT_TRUE(!((enum_type::foo | enum_type::bar) & enum_type::quux));
+TYPED_TEST(Enum, Functionalities) {
+    using enum_type = typename TestFixture::type;
 
-        ASSERT_TRUE(!!((enum_type::foo ^ enum_type::bar) & enum_type::foo));
-        ASSERT_TRUE(!((enum_type::foo ^ enum_type::foo) & enum_type::foo));
+    ASSERT_TRUE(!!((enum_type::foo | enum_type::bar) & enum_type::foo));
+    ASSERT_TRUE(!!((enum_type::foo | enum_type::bar) & enum_type::bar));
+    ASSERT_TRUE(!((enum_type::foo | enum_type::bar) & enum_type::quux));
 
-        ASSERT_TRUE(!(~enum_type::foo & enum_type::foo));
-        ASSERT_TRUE(!!(~enum_type::foo & enum_type::bar));
+    ASSERT_TRUE(!!((enum_type::foo ^ enum_type::bar) & enum_type::foo));
+    ASSERT_TRUE(!((enum_type::foo ^ enum_type::foo) & enum_type::foo));
 
-        ASSERT_TRUE(enum_type::foo == enum_type::foo);
-        ASSERT_TRUE(enum_type::foo != enum_type::bar);
+    ASSERT_TRUE(!(~enum_type::foo & enum_type::foo));
+    ASSERT_TRUE(!!(~enum_type::foo & enum_type::bar));
 
-        enum_type value = enum_type::foo;
+    ASSERT_TRUE(enum_type::foo == enum_type::foo);
+    ASSERT_TRUE(enum_type::foo != enum_type::bar);
 
-        ASSERT_TRUE(!!(value & enum_type::foo));
-        ASSERT_TRUE(!(value & enum_type::bar));
-        ASSERT_TRUE(!(value & enum_type::quux));
+    enum_type value = enum_type::foo;
 
-        value |= (enum_type::bar | enum_type::quux);
+    ASSERT_TRUE(!!(value & enum_type::foo));
+    ASSERT_TRUE(!(value & enum_type::bar));
+    ASSERT_TRUE(!(value & enum_type::quux));
 
-        ASSERT_TRUE(!!(value & enum_type::foo));
-        ASSERT_TRUE(!!(value & enum_type::bar));
-        ASSERT_TRUE(!!(value & enum_type::quux));
+    value |= (enum_type::bar | enum_type::quux);
 
-        value &= (enum_type::bar | enum_type::quux);
+    ASSERT_TRUE(!!(value & enum_type::foo));
+    ASSERT_TRUE(!!(value & enum_type::bar));
+    ASSERT_TRUE(!!(value & enum_type::quux));
 
-        ASSERT_TRUE(!(value & enum_type::foo));
-        ASSERT_TRUE(!!(value & enum_type::bar));
-        ASSERT_TRUE(!!(value & enum_type::quux));
+    value &= (enum_type::bar | enum_type::quux);
 
-        value ^= enum_type::bar;
+    ASSERT_TRUE(!(value & enum_type::foo));
+    ASSERT_TRUE(!!(value & enum_type::bar));
+    ASSERT_TRUE(!!(value & enum_type::quux));
 
-        ASSERT_TRUE(!(value & enum_type::foo));
-        ASSERT_TRUE(!(value & enum_type::bar));
-        ASSERT_TRUE(!!(value & enum_type::quux));
-    };
+    value ^= enum_type::bar;
 
-    test(entt::type_identity<detected>{});
-    test(entt::type_identity<registered>{});
+    ASSERT_TRUE(!(value & enum_type::foo));
+    ASSERT_TRUE(!(value & enum_type::bar));
+    ASSERT_TRUE(!!(value & enum_type::quux));
 }