DEV: minor changes
This commit is contained in:
+34
-13
@@ -95,7 +95,7 @@ namespace TmetaBasic {
|
||||
|
||||
EXPECT_EQ (true, (std::is_same<int_<42>, if_c<true, int_<42>, false_>>()));
|
||||
EXPECT_EQ (true, (std::is_same<Foo, if_c<false, int_<42>, Foo>>()));
|
||||
EXPECT_EQ (true, (std::is_same<Foo, if_c<42, Foo, Bar>>()));
|
||||
EXPECT_EQ (true, (std::is_same<Foo, if_c<(bool)42, Foo, Bar>>()));
|
||||
|
||||
EXPECT_EQ (true, (std::is_same<int_<42>, if_<true_, int_<42>, Bar>>()));
|
||||
EXPECT_EQ (true, (std::is_same<Bar, if_<false_, int_<42>, Bar>>()));
|
||||
@@ -165,24 +165,34 @@ namespace TmetaBasic {
|
||||
*/
|
||||
TEST(TmetaBasic, ComparisonOperations) {
|
||||
EXPECT_EQ (true, (comp_eq<int_<7>, int_<7>>()));
|
||||
EXPECT_EQ (true, (comp_eq<int_<-7>, int_<-7>>()));
|
||||
EXPECT_EQ (false, (comp_eq<int_<42>, int_<7>>()));
|
||||
|
||||
EXPECT_EQ (true, (comp_ne<int_<42>, int_<7>>()));
|
||||
EXPECT_EQ (false, (comp_ne<int_<42>, int_<42>>()));
|
||||
EXPECT_EQ (true, (comp_ne<int_<42>, int_<-42>>()));
|
||||
|
||||
EXPECT_EQ (true, (comp_lt<int_<42>, int_<43>>()));
|
||||
EXPECT_EQ (true, (comp_lt<int_<-7>, int_<-5>>()));
|
||||
EXPECT_EQ (false, (comp_lt<int_<43>, int_<42>>()));
|
||||
|
||||
EXPECT_EQ (true, (comp_gt<int_<43>, int_<42>>()));
|
||||
EXPECT_EQ (false, (comp_gt<int_<42>, int_<43>>()));
|
||||
EXPECT_EQ (true, (comp_gt<int_<42>, int_<7>>()));
|
||||
EXPECT_EQ (true, (comp_gt<int_<7>, int_<-42>>()));
|
||||
EXPECT_EQ (false, (comp_gt<int_<7>, int_<42>>()));
|
||||
|
||||
EXPECT_EQ (true, (comp_le<int_<42>, int_<43>>()));
|
||||
EXPECT_EQ (true, (comp_le<int_<7>, int_<42>>()));
|
||||
EXPECT_EQ (true, (comp_le<int_<-7>, int_<42>>()));
|
||||
EXPECT_EQ (true, (comp_le<int_<42>, int_<42>>()));
|
||||
EXPECT_EQ (false, (comp_le<int_<43>, int_<42>>()));
|
||||
EXPECT_EQ (true, (comp_le<int_<-7>, int_<-7>>()));
|
||||
EXPECT_EQ (false, (comp_le<int_<42>, int_<7>>()));
|
||||
EXPECT_EQ (false, (comp_le<int_<7>, int_<-42>>()));
|
||||
|
||||
EXPECT_EQ (true, (comp_ge<int_<43>, int_<42>>()));
|
||||
EXPECT_EQ (true, (comp_ge<int_<42>, int_<7>>()));
|
||||
EXPECT_EQ (true, (comp_ge<int_<42>, int_<-7>>()));
|
||||
EXPECT_EQ (true, (comp_ge<int_<42>, int_<42>>()));
|
||||
EXPECT_EQ (true, (comp_ge<int_<-7>, int_<-7>>()));
|
||||
EXPECT_EQ (false, (comp_ge<int_<42>, int_<43>>()));
|
||||
EXPECT_EQ (false, (comp_ge<int_<-7>, int_<42>>()));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -192,7 +202,12 @@ namespace TmetaBasic {
|
||||
EXPECT_EQ (0x00, (bitand_<uint8_<0x55>, uint8_<0xAA>>()));
|
||||
EXPECT_EQ (0xFF, (bitor_ <uint8_<0x55>, uint8_<0xAA>>()));
|
||||
EXPECT_EQ (0xFA, (bitxor_<uint8_<0x55>, uint8_<0xAF>>()));
|
||||
EXPECT_EQ (0x00, (bitnot_<uint8_<-1>>()));
|
||||
EXPECT_EQ (0x00, (bitnot_<uint8_<(uint8_t)-1>>()));
|
||||
|
||||
EXPECT_EQ (0x0000, (bitand_<uint16_<0x5555>, uint16_<0xAAAA>>()));
|
||||
EXPECT_EQ (0xFFFF, (bitor_ <uint16_<0x5555>, uint16_<0xAAAA>>()));
|
||||
EXPECT_EQ (0xFFAA, (bitxor_<uint16_<0x5555>, uint16_<0xAAFF>>()));
|
||||
EXPECT_EQ (0x0000, (bitnot_<uint16_<(uint16_t)-1>>()));
|
||||
|
||||
EXPECT_EQ (0x04, (shift_left<uint8_<0x01>, uint8_<2>>()));
|
||||
EXPECT_EQ (0x00, (shift_left<uint8_<0x80>, uint8_<1>>()));
|
||||
@@ -204,15 +219,21 @@ namespace TmetaBasic {
|
||||
* SFINAE
|
||||
*/
|
||||
template <typename T, typename =when<same_<T, int>::type::value>>
|
||||
int check (T x) { return x; }
|
||||
int check (...) { return 0; }
|
||||
int check1 (T x) { return x; }
|
||||
int check1 (...) { return 0; }
|
||||
|
||||
template <typename T, typename =enable_if_t<same_<T, int>::type::value, void>>
|
||||
int check2 (T x) { return x; }
|
||||
int check2 (...) { return 0; }
|
||||
|
||||
TEST(TmetaBasic, Sfinae) {
|
||||
EXPECT_EQ (42, check(42));
|
||||
EXPECT_EQ (0, check(42.0));
|
||||
EXPECT_EQ (0, check());
|
||||
EXPECT_EQ (42, check1(42));
|
||||
EXPECT_EQ (0, check1(42.0));
|
||||
EXPECT_EQ (0, check1());
|
||||
|
||||
// enable_if is imported so we trust stl and skip testing it
|
||||
EXPECT_EQ (42, check2(42));
|
||||
EXPECT_EQ (0, check2(42.0));
|
||||
EXPECT_EQ (0, check2());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -98,7 +98,6 @@ namespace TmetaDetection {
|
||||
EXPECT_EQ (false,(is_detected_v<try_none, A<int>>));
|
||||
EXPECT_EQ (true, (is_detected_v<mFun, int, void>));
|
||||
|
||||
// typePrinter (detected_t<try_none, A>{});
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -153,8 +153,8 @@ namespace TmetaTypelist {
|
||||
EXPECT_EQ (true, (std::is_same<l2, repeat_c <2, int, void*>>()));
|
||||
|
||||
|
||||
EXPECT_EQ (3, size<l1>());
|
||||
EXPECT_EQ (0, size<l3>());
|
||||
EXPECT_EQ (3U, size<l1>());
|
||||
EXPECT_EQ (0U, size<l3>());
|
||||
EXPECT_EQ (true, empty<l3>());
|
||||
|
||||
// pass typelist to an invocable
|
||||
@@ -323,20 +323,4 @@ namespace TmetaTypelist {
|
||||
EXPECT_EQ (true, (std::is_same<true_, none_of<l3, quote<Pred_isInt>>>()));
|
||||
}
|
||||
|
||||
/*
|
||||
* Detection idiom
|
||||
*/
|
||||
TEST(Tmeta, DetectionVoidType) {
|
||||
struct Foo {};
|
||||
struct Bar {};
|
||||
EXPECT_EQ(true, (std::is_same<void, void_t<int, long, void*, void, Foo, Bar>>()));
|
||||
EXPECT_EQ(true, (std::is_same<void, void_t<>>()));
|
||||
}
|
||||
|
||||
TEST(Tmeta, DetectionNotAType) {
|
||||
EXPECT_EQ(false, (std::is_default_constructible<nat_>()));
|
||||
EXPECT_EQ(false, (std::is_destructible<nat_>()));
|
||||
EXPECT_EQ(false, (std::is_copy_constructible<nat_>()));
|
||||
EXPECT_EQ(false, (std::is_copy_assignable<nat_>()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user