#include #include #include #include struct C0 {}; struct C1 {}; struct C2 {}; struct C3 {}; struct T0 {}; struct T1 {}; using ListComponentsAll = EC::Meta::TypeList; using ListComponentsSome = EC::Meta::TypeList; using ListTagsAll = EC::Meta::TypeList; using ListAll = EC::Meta::TypeList; using ListSome = EC::Meta::TypeList; template struct Storage { using type = std::tuple... >; }; TEST(Meta, Contains) { int size = ListComponentsAll::size; EXPECT_EQ(size, 4); bool result = EC::Meta::Contains::value; EXPECT_TRUE(result); result = EC::Meta::Contains::value; EXPECT_TRUE(result); result = EC::Meta::Contains::value; EXPECT_TRUE(result); result = EC::Meta::Contains::value; EXPECT_TRUE(result); size = ListComponentsSome::size; EXPECT_EQ(size, 2); result = EC::Meta::Contains::value; EXPECT_FALSE(result); result = EC::Meta::Contains::value; EXPECT_TRUE(result); result = EC::Meta::Contains::value; EXPECT_FALSE(result); result = EC::Meta::Contains::value; EXPECT_TRUE(result); } TEST(Meta, ContainsAll) { bool contains = EC::Meta::ContainsAll::value; EXPECT_TRUE(contains); contains = EC::Meta::ContainsAll::value; EXPECT_FALSE(contains); contains = EC::Meta::ContainsAll::value; EXPECT_TRUE(contains); } TEST(Meta, IndexOf) { int index = EC::Meta::IndexOf::value; EXPECT_EQ(index, 0); index = EC::Meta::IndexOf::value; EXPECT_EQ(index, 1); index = EC::Meta::IndexOf::value; EXPECT_EQ(index, 2); index = EC::Meta::IndexOf::value; EXPECT_EQ(index, 3); index = EC::Meta::IndexOf::value; EXPECT_EQ(index, 4); index = EC::Meta::IndexOf::value; EXPECT_EQ(index, 0); index = EC::Meta::IndexOf::value; EXPECT_EQ(index, 1); index = EC::Meta::IndexOf::value; EXPECT_EQ(index, 2); } TEST(Meta, Bitset) { EC::Bitset bitset; EXPECT_EQ(bitset.size(), ListComponentsAll::size + ListTagsAll::size + 1); bitset[EC::Meta::IndexOf::value] = true; EXPECT_TRUE(bitset.getComponentBit()); bitset.flip(); EXPECT_FALSE(bitset.getComponentBit()); bitset.reset(); bitset[ListComponentsAll::size + EC::Meta::IndexOf::value] = true; EXPECT_TRUE(bitset.getTagBit()); bitset.flip(); EXPECT_FALSE(bitset.getTagBit()); } TEST(Meta, Combine) { using CombinedAll = EC::Meta::Combine; int listAllTemp = ListAll::size; int combinedAllTemp = CombinedAll::size; EXPECT_EQ(combinedAllTemp, listAllTemp); listAllTemp = EC::Meta::IndexOf::value; combinedAllTemp = EC::Meta::IndexOf::value; EXPECT_EQ(combinedAllTemp, listAllTemp); listAllTemp = EC::Meta::IndexOf::value; combinedAllTemp = EC::Meta::IndexOf::value; EXPECT_EQ(combinedAllTemp, listAllTemp); listAllTemp = EC::Meta::IndexOf::value; combinedAllTemp = EC::Meta::IndexOf::value; EXPECT_EQ(combinedAllTemp, listAllTemp); listAllTemp = EC::Meta::IndexOf::value; combinedAllTemp = EC::Meta::IndexOf::value; EXPECT_EQ(combinedAllTemp, listAllTemp); listAllTemp = EC::Meta::IndexOf::value; combinedAllTemp = EC::Meta::IndexOf::value; EXPECT_EQ(combinedAllTemp, listAllTemp); listAllTemp = EC::Meta::IndexOf::value; combinedAllTemp = EC::Meta::IndexOf::value; EXPECT_EQ(combinedAllTemp, listAllTemp); bool same = std::is_same::value; EXPECT_TRUE(same); } TEST(Meta, Morph) { using TupleAll = std::tuple; using MorphedTuple = EC::Meta::Morph >; int morphedTupleTemp = MorphedTuple::size; int componentsTemp = ListComponentsAll::size; EXPECT_EQ(morphedTupleTemp, componentsTemp); morphedTupleTemp = EC::Meta::IndexOf::value; componentsTemp = EC::Meta::IndexOf::value; EXPECT_EQ(morphedTupleTemp, componentsTemp); morphedTupleTemp = EC::Meta::IndexOf::value; componentsTemp = EC::Meta::IndexOf::value; EXPECT_EQ(morphedTupleTemp, componentsTemp); morphedTupleTemp = EC::Meta::IndexOf::value; componentsTemp = EC::Meta::IndexOf::value; EXPECT_EQ(morphedTupleTemp, componentsTemp); morphedTupleTemp = EC::Meta::IndexOf::value; componentsTemp = EC::Meta::IndexOf::value; EXPECT_EQ(morphedTupleTemp, componentsTemp); using MorphedComponents = EC::Meta::Morph >; bool isSame = std::is_same::value; EXPECT_TRUE(isSame); using ComponentsStorage = EC::Meta::Morph >; isSame = std::is_same, std::vector, std::vector, std::vector > >::value; EXPECT_TRUE(isSame); } TEST(Meta, TypeListGet) { bool isSame = std::is_same >::value; EXPECT_TRUE(isSame); isSame = std::is_same >::value; EXPECT_TRUE(isSame); isSame = std::is_same >::value; EXPECT_TRUE(isSame); isSame = std::is_same >::value; EXPECT_TRUE(isSame); const unsigned int temp = 4; isSame = std::is_same >::value; EXPECT_TRUE(isSame); isSame = std::is_same >::value; EXPECT_TRUE(isSame); } TEST(Meta, ForEach) { EC::Bitset bitset; auto setBits = [&bitset] (auto t) { bitset[EC::Meta::IndexOf::value] = true; }; EC::Meta::forEach(setBits); EXPECT_FALSE(bitset[0]); EXPECT_TRUE(bitset[1]); EXPECT_FALSE(bitset[2]); EXPECT_TRUE(bitset[3]); EXPECT_FALSE(bitset[4]); EXPECT_FALSE(bitset[5]); } TEST(Meta, Matching) { { using Matched = EC::Meta::Matching::type; bool isSame = std::is_same::value; EXPECT_TRUE(isSame); } { using Matched = EC::Meta::Matching::type; bool isSame = std::is_same::value; EXPECT_TRUE(isSame); } { using Matched = EC::Meta::Matching::type; bool isSame = std::is_same, Matched>::value; EXPECT_TRUE(isSame); } }