1 #include "../misc/traits.h"
2 #include "../tests/testutils.h"
4 #include <cppunit/TestFixture.h>
5 #include <cppunit/extensions/HelperMacros.h>
7 #include <forward_list>
17 using namespace CPPUNIT_NS;
25 struct CountableStruct {
26 int numberOfElements = 42;
30 struct TestIncomplete;
61 static_assert(!IsDereferencable<string>::value,
"IsDereferencable: negative case");
62 static_assert(!IsDereferencable<int>::value,
"IsDereferencable: negative case");
63 static_assert(IsDereferencable<string *>::value,
"IsDereferencable: positive case");
64 static_assert(IsDereferencable<int *>::value,
"IsDereferencable: positive case");
65 static_assert(IsDereferencable<unique_ptr<string>>::value,
"IsDereferencable: positive case");
66 static_assert(IsDereferencable<shared_ptr<string>>::value,
"IsDereferencable: positive case");
67 static_assert(!IsDereferencable<weak_ptr<string>>::value,
"IsDereferencable: positive case");
69 static_assert(!IsIteratable<int>::value,
"IsIterator: negative case");
70 static_assert(!IsIteratable<SomeStruct>::value,
"IsIterator: negative case");
71 static_assert(IsIteratable<string>::value,
"IsIterator: positive case");
72 static_assert(IsIteratable<vector<int>>::value,
"IsIterator: positive case");
73 static_assert(IsIteratable<list<string>>::value,
"IsIterator: positive case");
74 static_assert(IsIteratable<map<string, string>>::value,
"IsIterator: positive case");
75 static_assert(IsIteratable<initializer_list<double>>::value,
"IsIterator: positive case");
76 static_assert(!HasSize<SomeStruct>::value,
"HasSize: negative case");
77 static_assert(!HasSize<forward_list<SomeStruct>>::value,
"HasSize: negative case");
78 static_assert(HasSize<vector<SomeStruct>>::value,
"HasSize: positive case");
79 static_assert(HasSize<string>::value,
"HasSize: positive case");
80 static_assert(HasSize<CountableStruct>::value,
"HasSize: positive case");
81 static_assert(!IsReservable<list<SomeStruct>>::value,
"HasSize: negative case");
82 static_assert(IsReservable<vector<SomeStruct>>::value,
"HasSize: positive case");
83 static_assert(HasOperatorBool<
function<
void(
void)>>::value,
"HasOperatorBool: positive case");
84 static_assert(!HasOperatorBool<SomeStruct>::value,
"HasOperatorBool: negative case");
87 static_assert(!
IsCString<
int[]>::value,
"IsCString: negative case");
89 static_assert(
IsCString<
char[]>::value,
"IsCString: positive case");
115 CPPUNIT_TEST(testDereferenceMaybe);
116 CPPUNIT_TEST_SUITE_END();
126 void testDereferenceMaybe();
136 const auto someString =
"foo"s;
137 const auto someSmartPointer = make_unique<string>(
"foo");