From 7faa51c10ed53e91169f48a7e5fd3cb3018fac5b Mon Sep 17 00:00:00 2001 From: Martchus Date: Mon, 8 May 2017 19:59:29 +0200 Subject: [PATCH] Test traits --- CMakeLists.txt | 1 + tests/traitstests.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 tests/traitstests.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index db020f5..f48945b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,7 @@ set(TEST_SRC_FILES tests/iotests.cpp tests/chronotests.cpp tests/argumentparsertests.cpp + tests/traitstests.cpp ) set(CMAKE_MODULE_FILES diff --git a/tests/traitstests.cpp b/tests/traitstests.cpp new file mode 100644 index 0000000..7111e08 --- /dev/null +++ b/tests/traitstests.cpp @@ -0,0 +1,33 @@ +#include "../misc/traits.h" + +#include +#include +#include +#include + +using namespace std; +using namespace Traits; + +struct SomeStruct { + string foo; + int bar; +}; + +static_assert(!Bool::value, "Bool"); +static_assert(Bool::value, "Bool"); +static_assert(!Not>::value, "Not"); +static_assert(!Any, Bool>::value, "Any: negative case"); +static_assert(Any, Bool>::value, "Any: positive case"); +static_assert(!All, Bool>::value, "All: negative case"); +static_assert(All, Bool>::value, "All: positive case"); + +static_assert(!IsSpecializationOf::value, "IsSpecializationOf: negative case"); +static_assert(IsSpecializationOf::value, "IsSpecializationOf: positive case"); + +static_assert(!IsIteratable::value, "IsIterator: negative case"); +static_assert(!IsIteratable::value, "IsIterator: negative case"); +static_assert(IsIteratable::value, "IsIterator: positive case"); +static_assert(IsIteratable>::value, "IsIterator: positive case"); +static_assert(IsIteratable>::value, "IsIterator: positive case"); +static_assert(IsIteratable>::value, "IsIterator: positive case"); +static_assert(IsIteratable>::value, "IsIterator: positive case");