update test
This commit is contained in:
parent
e2b0991a04
commit
fa5057bea4
2 changed files with 96 additions and 74 deletions
|
@ -3,11 +3,3 @@ include_directories(${CMAKE_SOURCE_DIR}/include)
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME}_test test.cpp)
|
add_executable(${PROJECT_NAME}_test test.cpp)
|
||||||
add_test(NAME ${PROJECT_NAME}_test COMMAND ${PROJECT_NAME}_test)
|
add_test(NAME ${PROJECT_NAME}_test COMMAND ${PROJECT_NAME}_test)
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME}_test_no_rtti test.cpp)
|
|
||||||
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
|
||||||
target_compile_options(${PROJECT_NAME}_test_no_rtti PUBLIC -fno-rtti)
|
|
||||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|
||||||
target_compile_options(${PROJECT_NAME}_test_no_rtti PUBLIC /GR-)
|
|
||||||
endif()
|
|
||||||
add_test(NAME ${PROJECT_NAME}_test_no_rtti COMMAND ${PROJECT_NAME}_test_no_rtti)
|
|
||||||
|
|
162
test/test.cpp
162
test/test.cpp
|
@ -41,8 +41,8 @@ void SomeMethod3() {
|
||||||
std::cout << NAMEOF(SomeMethod3) << " no called!" << std::endl;
|
std::cout << NAMEOF(SomeMethod3) << " no called!" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T, typename U>
|
||||||
T SomeMethod4() {
|
T SomeMethod4(U value) {
|
||||||
return T{};
|
return T{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,19 +70,21 @@ struct Long {
|
||||||
|
|
||||||
enum class Color { RED, GREEN, BLUE };
|
enum class Color { RED, GREEN, BLUE };
|
||||||
|
|
||||||
SomeStruct structvar;
|
SomeStruct struct_var;
|
||||||
Long othervar;
|
Long othervar;
|
||||||
SomeStruct * ptrvar = &structvar;
|
SomeStruct * ptr_s = &struct_var;
|
||||||
SomeStruct & refvar = structvar;
|
SomeStruct & ref_s = struct_var;
|
||||||
const SomeClass<int> volatile * classvar;
|
|
||||||
|
SomeClass<int> class_var;
|
||||||
|
const SomeClass<int> volatile * ptr_c = nullptr;
|
||||||
|
|
||||||
TEST_CASE("constexpr") {
|
TEST_CASE("constexpr") {
|
||||||
SECTION("NAMEOF") {
|
SECTION("NAMEOF") {
|
||||||
// variable
|
// variable
|
||||||
constexpr auto cx1 = NAMEOF(structvar);
|
constexpr auto cx1 = NAMEOF(struct_var);
|
||||||
static_assert(cx1 == "structvar", "");
|
static_assert(cx1 == "struct_var", "");
|
||||||
// member
|
// member
|
||||||
constexpr auto cx2 = NAMEOF((&structvar)->somefield);
|
constexpr auto cx2 = NAMEOF((&struct_var)->somefield);
|
||||||
static_assert(cx2 == "somefield", "");
|
static_assert(cx2 == "somefield", "");
|
||||||
// function
|
// function
|
||||||
constexpr auto cx3 = NAMEOF(&SomeClass<int>::SomeMethod6<long int>);
|
constexpr auto cx3 = NAMEOF(&SomeClass<int>::SomeMethod6<long int>);
|
||||||
|
@ -94,10 +96,10 @@ TEST_CASE("constexpr") {
|
||||||
|
|
||||||
SECTION("NAMEOF_FULL") {
|
SECTION("NAMEOF_FULL") {
|
||||||
// variable
|
// variable
|
||||||
constexpr auto cx1 = NAMEOF_FULL(structvar);
|
constexpr auto cx1 = NAMEOF_FULL(struct_var);
|
||||||
static_assert(cx1 == "structvar", "");
|
static_assert(cx1 == "struct_var", "");
|
||||||
// member
|
// member
|
||||||
constexpr auto cx2 = NAMEOF_FULL((&structvar)->somefield);
|
constexpr auto cx2 = NAMEOF_FULL((&struct_var)->somefield);
|
||||||
static_assert(cx2 == "somefield", "");
|
static_assert(cx2 == "somefield", "");
|
||||||
// function
|
// function
|
||||||
constexpr auto cx3 = NAMEOF_FULL(&SomeClass<int>::SomeMethod6<long int>);
|
constexpr auto cx3 = NAMEOF_FULL(&SomeClass<int>::SomeMethod6<long int>);
|
||||||
|
@ -109,11 +111,11 @@ TEST_CASE("constexpr") {
|
||||||
|
|
||||||
SECTION("NAMEOF_RAW") {
|
SECTION("NAMEOF_RAW") {
|
||||||
// variable
|
// variable
|
||||||
constexpr auto cx1 = NAMEOF_RAW(structvar);
|
constexpr auto cx1 = NAMEOF_RAW(struct_var);
|
||||||
static_assert(cx1 == "structvar", "");
|
static_assert(cx1 == "struct_var", "");
|
||||||
// member
|
// member
|
||||||
constexpr auto cx2 = NAMEOF_RAW((&structvar)->somefield);
|
constexpr auto cx2 = NAMEOF_RAW((&struct_var)->somefield);
|
||||||
static_assert(cx2 == "(&structvar)->somefield", "");
|
static_assert(cx2 == "(&struct_var)->somefield", "");
|
||||||
// function
|
// function
|
||||||
constexpr auto cx4 = NAMEOF_RAW(&SomeStruct::SomeMethod2);
|
constexpr auto cx4 = NAMEOF_RAW(&SomeStruct::SomeMethod2);
|
||||||
static_assert(cx4 == "&SomeStruct::SomeMethod2", "");
|
static_assert(cx4 == "&SomeStruct::SomeMethod2", "");
|
||||||
|
@ -124,9 +126,10 @@ TEST_CASE("constexpr") {
|
||||||
constexpr auto cx6 = NAMEOF_RAW(__cplusplus);
|
constexpr auto cx6 = NAMEOF_RAW(__cplusplus);
|
||||||
static_assert(cx6 == "__cplusplus", "");
|
static_assert(cx6 == "__cplusplus", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(NAMEOF_TYPE_HAS_CONSTEXPR)
|
#if defined(NAMEOF_TYPE_HAS_CONSTEXPR)
|
||||||
SECTION("NAMEOF_TYPE") {
|
SECTION("NAMEOF_TYPE") {
|
||||||
constexpr auto cx = NAMEOF_TYPE(classvar);
|
constexpr auto cx = NAMEOF_TYPE(ptr_c);
|
||||||
# if defined(__clang__)
|
# if defined(__clang__)
|
||||||
static_assert(cx == "const volatile SomeClass<int> *", "");
|
static_assert(cx == "const volatile SomeClass<int> *", "");
|
||||||
# elif defined(_MSC_VER)
|
# elif defined(_MSC_VER)
|
||||||
|
@ -147,24 +150,32 @@ TEST_CASE("constexpr") {
|
||||||
|
|
||||||
TEST_CASE("NAMEOF") {
|
TEST_CASE("NAMEOF") {
|
||||||
SECTION("variable") {
|
SECTION("variable") {
|
||||||
REQUIRE(NAMEOF(structvar) == "structvar");
|
REQUIRE(NAMEOF(othervar) == "othervar");
|
||||||
REQUIRE(NAMEOF(::structvar) == "structvar");
|
REQUIRE(NAMEOF(struct_var) == "struct_var");
|
||||||
REQUIRE(NAMEOF(ptrvar) == "ptrvar");
|
REQUIRE(NAMEOF(::struct_var) == "struct_var");
|
||||||
|
REQUIRE(NAMEOF(ptr_s) == "ptr_s");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("member") {
|
SECTION("member") {
|
||||||
REQUIRE(NAMEOF(structvar.somefield) == "somefield");
|
REQUIRE(NAMEOF(struct_var.somefield) == "somefield");
|
||||||
REQUIRE(NAMEOF((&structvar)->somefield) == "somefield");
|
REQUIRE(NAMEOF(struct_var.somefield++) == "somefield");
|
||||||
|
REQUIRE(NAMEOF((&struct_var)->somefield) == "somefield");
|
||||||
REQUIRE(NAMEOF(othervar.ll.field) == "field");
|
REQUIRE(NAMEOF(othervar.ll.field) == "field");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("function") {
|
SECTION("function") {
|
||||||
REQUIRE(NAMEOF(&SomeStruct::SomeMethod1) == "SomeMethod1");
|
REQUIRE(NAMEOF(&SomeStruct::SomeMethod1) == "SomeMethod1");
|
||||||
|
REQUIRE(NAMEOF(struct_var.SomeMethod1(1)) == "SomeMethod1");
|
||||||
REQUIRE(NAMEOF(&SomeStruct::SomeMethod2) == "SomeMethod2");
|
REQUIRE(NAMEOF(&SomeStruct::SomeMethod2) == "SomeMethod2");
|
||||||
|
REQUIRE(NAMEOF(struct_var.SomeMethod2()) == "SomeMethod2");
|
||||||
REQUIRE(NAMEOF(SomeMethod3) == "SomeMethod3");
|
REQUIRE(NAMEOF(SomeMethod3) == "SomeMethod3");
|
||||||
REQUIRE(NAMEOF(SomeMethod4<int>) == "SomeMethod4");
|
REQUIRE(NAMEOF(SomeMethod3()) == "SomeMethod3");
|
||||||
|
REQUIRE(NAMEOF(SomeMethod4<int, float>) == "SomeMethod4");
|
||||||
|
REQUIRE(NAMEOF(SomeMethod4<int, float>(1.0f)) == "SomeMethod4");
|
||||||
REQUIRE(NAMEOF(&SomeClass<int>::SomeMethod5) == "SomeMethod5");
|
REQUIRE(NAMEOF(&SomeClass<int>::SomeMethod5) == "SomeMethod5");
|
||||||
|
REQUIRE(NAMEOF(class_var.SomeMethod5()) == "SomeMethod5");
|
||||||
REQUIRE(NAMEOF(&SomeClass<int>::SomeMethod6<long int>) == "SomeMethod6");
|
REQUIRE(NAMEOF(&SomeClass<int>::SomeMethod6<long int>) == "SomeMethod6");
|
||||||
|
REQUIRE(NAMEOF(class_var.SomeMethod6<long int>()) == "SomeMethod6");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("enum") {
|
SECTION("enum") {
|
||||||
|
@ -175,24 +186,32 @@ TEST_CASE("NAMEOF") {
|
||||||
|
|
||||||
TEST_CASE("NAMEOF_FULL") {
|
TEST_CASE("NAMEOF_FULL") {
|
||||||
SECTION("variable") {
|
SECTION("variable") {
|
||||||
REQUIRE(NAMEOF_FULL(structvar) == "structvar");
|
REQUIRE(NAMEOF_FULL(othervar) == "othervar");
|
||||||
REQUIRE(NAMEOF_FULL(::structvar) == "structvar");
|
REQUIRE(NAMEOF_FULL(struct_var) == "struct_var");
|
||||||
REQUIRE(NAMEOF_FULL(ptrvar) == "ptrvar");
|
REQUIRE(NAMEOF_FULL(::struct_var) == "struct_var");
|
||||||
|
REQUIRE(NAMEOF_FULL(ptr_s) == "ptr_s");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("member") {
|
SECTION("member") {
|
||||||
REQUIRE(NAMEOF_FULL(structvar.somefield) == "somefield");
|
REQUIRE(NAMEOF_FULL(struct_var.somefield) == "somefield");
|
||||||
REQUIRE(NAMEOF_FULL((&structvar)->somefield) == "somefield");
|
REQUIRE(NAMEOF_FULL(struct_var.somefield++) == "somefield");
|
||||||
|
REQUIRE(NAMEOF_FULL((&struct_var)->somefield) == "somefield");
|
||||||
REQUIRE(NAMEOF_FULL(othervar.ll.field) == "field");
|
REQUIRE(NAMEOF_FULL(othervar.ll.field) == "field");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("function") {
|
SECTION("function") {
|
||||||
REQUIRE(NAMEOF_FULL(&SomeStruct::SomeMethod1) == "SomeMethod1");
|
REQUIRE(NAMEOF_FULL(&SomeStruct::SomeMethod1) == "SomeMethod1");
|
||||||
|
REQUIRE(NAMEOF_FULL(struct_var.SomeMethod1(1)) == "SomeMethod1");
|
||||||
REQUIRE(NAMEOF_FULL(&SomeStruct::SomeMethod2) == "SomeMethod2");
|
REQUIRE(NAMEOF_FULL(&SomeStruct::SomeMethod2) == "SomeMethod2");
|
||||||
|
REQUIRE(NAMEOF_FULL(struct_var.SomeMethod2()) == "SomeMethod2");
|
||||||
REQUIRE(NAMEOF_FULL(SomeMethod3) == "SomeMethod3");
|
REQUIRE(NAMEOF_FULL(SomeMethod3) == "SomeMethod3");
|
||||||
REQUIRE(NAMEOF_FULL(SomeMethod4<int>) == "SomeMethod4<int>");
|
REQUIRE(NAMEOF_FULL(SomeMethod3()) == "SomeMethod3");
|
||||||
|
REQUIRE(NAMEOF_FULL(SomeMethod4<int, float>) == "SomeMethod4<int, float>");
|
||||||
|
REQUIRE(NAMEOF_FULL(SomeMethod4<int, float>(1.0f)) == "SomeMethod4<int, float>");
|
||||||
REQUIRE(NAMEOF_FULL(&SomeClass<int>::SomeMethod5) == "SomeMethod5");
|
REQUIRE(NAMEOF_FULL(&SomeClass<int>::SomeMethod5) == "SomeMethod5");
|
||||||
|
REQUIRE(NAMEOF_FULL(class_var.SomeMethod5()) == "SomeMethod5");
|
||||||
REQUIRE(NAMEOF_FULL(&SomeClass<int>::SomeMethod6<long int>) == "SomeMethod6<long int>");
|
REQUIRE(NAMEOF_FULL(&SomeClass<int>::SomeMethod6<long int>) == "SomeMethod6<long int>");
|
||||||
|
REQUIRE(NAMEOF_FULL(class_var.SomeMethod6<long int>()) == "SomeMethod6<long int>");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("enum") {
|
SECTION("enum") {
|
||||||
|
@ -203,28 +222,39 @@ TEST_CASE("NAMEOF_FULL") {
|
||||||
|
|
||||||
TEST_CASE("NAMEOF_RAW") {
|
TEST_CASE("NAMEOF_RAW") {
|
||||||
SECTION("variable") {
|
SECTION("variable") {
|
||||||
REQUIRE(NAMEOF_RAW(structvar) == "structvar");
|
REQUIRE(NAMEOF_RAW(othervar) == "othervar");
|
||||||
REQUIRE(NAMEOF_RAW(&structvar) == "&structvar");
|
REQUIRE(NAMEOF_RAW(struct_var) == "struct_var");
|
||||||
REQUIRE(NAMEOF_RAW(::structvar) == "::structvar");
|
REQUIRE(NAMEOF_RAW(&struct_var) == "&struct_var");
|
||||||
REQUIRE(NAMEOF_RAW(ptrvar) == "ptrvar");
|
REQUIRE(NAMEOF_RAW(::struct_var) == "::struct_var");
|
||||||
REQUIRE(NAMEOF_RAW(*ptrvar) == "*ptrvar");
|
REQUIRE(NAMEOF_RAW(ptr_s) == "ptr_s");
|
||||||
REQUIRE(NAMEOF_RAW(+structvar.somefield) == "+structvar.somefield");
|
REQUIRE(NAMEOF_RAW(*ptr_s) == "*ptr_s");
|
||||||
REQUIRE(NAMEOF_RAW(-structvar.somefield) == "-structvar.somefield");
|
|
||||||
REQUIRE(NAMEOF_RAW(~structvar.somefield) == "~structvar.somefield");
|
|
||||||
REQUIRE(NAMEOF_RAW(!structvar.somefield) == "!structvar.somefield");
|
|
||||||
REQUIRE(NAMEOF_RAW(structvar.somefield + refvar.somefield) == "structvar.somefield + refvar.somefield");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("member") {
|
SECTION("member") {
|
||||||
REQUIRE(NAMEOF_RAW(structvar.somefield) == "structvar.somefield");
|
REQUIRE(NAMEOF_RAW(struct_var.somefield) == "struct_var.somefield");
|
||||||
REQUIRE(NAMEOF_RAW((&structvar)->somefield) == "(&structvar)->somefield");
|
REQUIRE(NAMEOF_RAW(struct_var.somefield++) == "struct_var.somefield++");
|
||||||
|
REQUIRE(NAMEOF_RAW((&struct_var)->somefield) == "(&struct_var)->somefield");
|
||||||
REQUIRE(NAMEOF_RAW(othervar.ll.field) == "othervar.ll.field");
|
REQUIRE(NAMEOF_RAW(othervar.ll.field) == "othervar.ll.field");
|
||||||
|
REQUIRE(NAMEOF_RAW(+struct_var.somefield) == "+struct_var.somefield");
|
||||||
|
REQUIRE(NAMEOF_RAW(-struct_var.somefield) == "-struct_var.somefield");
|
||||||
|
REQUIRE(NAMEOF_RAW(~struct_var.somefield) == "~struct_var.somefield");
|
||||||
|
REQUIRE(NAMEOF_RAW(!struct_var.somefield) == "!struct_var.somefield");
|
||||||
|
REQUIRE(NAMEOF_RAW(struct_var.somefield + ref_s.somefield) == "struct_var.somefield + ref_s.somefield");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("function") {
|
SECTION("function") {
|
||||||
REQUIRE(NAMEOF_RAW(&SomeStruct::SomeMethod1) == "&SomeStruct::SomeMethod1");
|
REQUIRE(NAMEOF_RAW(&SomeStruct::SomeMethod1) == "&SomeStruct::SomeMethod1");
|
||||||
|
REQUIRE(NAMEOF_RAW(struct_var.SomeMethod1(1)) == "struct_var.SomeMethod1(1)");
|
||||||
REQUIRE(NAMEOF_RAW(&SomeStruct::SomeMethod2) == "&SomeStruct::SomeMethod2");
|
REQUIRE(NAMEOF_RAW(&SomeStruct::SomeMethod2) == "&SomeStruct::SomeMethod2");
|
||||||
|
REQUIRE(NAMEOF_RAW(struct_var.SomeMethod2()) == "struct_var.SomeMethod2()");
|
||||||
REQUIRE(NAMEOF_RAW(SomeMethod3) == "SomeMethod3");
|
REQUIRE(NAMEOF_RAW(SomeMethod3) == "SomeMethod3");
|
||||||
|
REQUIRE(NAMEOF_RAW(SomeMethod3()) == "SomeMethod3()");
|
||||||
|
REQUIRE(NAMEOF_RAW(SomeMethod4<int, float>) == "SomeMethod4<int, float>");
|
||||||
|
REQUIRE(NAMEOF_RAW(SomeMethod4<int, float>(1.0f)) == "SomeMethod4<int, float>(1.0f)");
|
||||||
|
REQUIRE(NAMEOF_RAW(&SomeClass<int>::SomeMethod5) == "&SomeClass<int>::SomeMethod5");
|
||||||
|
REQUIRE(NAMEOF_RAW(class_var.SomeMethod5()) == "class_var.SomeMethod5()");
|
||||||
|
REQUIRE(NAMEOF_RAW(&SomeClass<int>::SomeMethod6<long int>) == "&SomeClass<int>::SomeMethod6<long int>");
|
||||||
|
REQUIRE(NAMEOF_RAW(class_var.SomeMethod6<long int>()) == "class_var.SomeMethod6<long int>()");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("enum") {
|
SECTION("enum") {
|
||||||
|
@ -241,8 +271,8 @@ TEST_CASE("NAMEOF_RAW") {
|
||||||
|
|
||||||
TEST_CASE("NAMEOF_TYPE") {
|
TEST_CASE("NAMEOF_TYPE") {
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
REQUIRE(NAMEOF_TYPE(structvar) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE(struct_var) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE(ptrvar) == "SomeStruct *");
|
REQUIRE(NAMEOF_TYPE(ptr_s) == "SomeStruct *");
|
||||||
REQUIRE(NAMEOF_TYPE(refvar) == "SomeStruct &");
|
REQUIRE(NAMEOF_TYPE(refvar) == "SomeStruct &");
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE(classvar) == "const volatile SomeClass<int> *");
|
REQUIRE(NAMEOF_TYPE(classvar) == "const volatile SomeClass<int> *");
|
||||||
|
@ -255,11 +285,11 @@ TEST_CASE("NAMEOF_TYPE") {
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE(std::declval<const SomeClass<int>>()) == "const SomeClass<int> &&");
|
REQUIRE(NAMEOF_TYPE(std::declval<const SomeClass<int>>()) == "const SomeClass<int> &&");
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
REQUIRE(NAMEOF_TYPE(structvar) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE(struct_var) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE(ptrvar) == "SomeStruct *");
|
REQUIRE(NAMEOF_TYPE(ptr_s) == "SomeStruct *");
|
||||||
REQUIRE(NAMEOF_TYPE(refvar) == "SomeStruct &");
|
REQUIRE(NAMEOF_TYPE(ref_s) == "SomeStruct &");
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE(classvar) == "SomeClass<int> const volatile *");
|
REQUIRE(NAMEOF_TYPE(ptr_c) == "SomeClass<int> const volatile *");
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE(othervar) == "Long");
|
REQUIRE(NAMEOF_TYPE(othervar) == "Long");
|
||||||
REQUIRE(NAMEOF_TYPE(othervar.ll) == "Long::LL");
|
REQUIRE(NAMEOF_TYPE(othervar.ll) == "Long::LL");
|
||||||
|
@ -269,8 +299,8 @@ TEST_CASE("NAMEOF_TYPE") {
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE(std::declval<const SomeClass<int>>()) == "SomeClass<int> const &&");
|
REQUIRE(NAMEOF_TYPE(std::declval<const SomeClass<int>>()) == "SomeClass<int> const &&");
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
REQUIRE(NAMEOF_TYPE(structvar) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE(struct_var) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE(ptrvar) == "SomeStruct*");
|
REQUIRE(NAMEOF_TYPE(ptr_s) == "SomeStruct*");
|
||||||
REQUIRE(NAMEOF_TYPE(refvar) == "SomeStruct&");
|
REQUIRE(NAMEOF_TYPE(refvar) == "SomeStruct&");
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE(classvar) == "const volatile SomeClass<int>*");
|
REQUIRE(NAMEOF_TYPE(classvar) == "const volatile SomeClass<int>*");
|
||||||
|
@ -287,8 +317,8 @@ TEST_CASE("NAMEOF_TYPE") {
|
||||||
|
|
||||||
TEST_CASE("NAMEOF_TYPE_T") {
|
TEST_CASE("NAMEOF_TYPE_T") {
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
REQUIRE(NAMEOF_TYPE_T(decltype(structvar)) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE_T(decltype(struct_var)) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE_T(decltype(ptrvar)) == "SomeStruct *");
|
REQUIRE(NAMEOF_TYPE_T(decltype(ptr_s)) == "SomeStruct *");
|
||||||
REQUIRE(NAMEOF_TYPE_T(decltype(refvar)) == "SomeStruct &");
|
REQUIRE(NAMEOF_TYPE_T(decltype(refvar)) == "SomeStruct &");
|
||||||
REQUIRE(NAMEOF_TYPE_T(SomeStruct) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE_T(SomeStruct) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE_T(SomeStruct *) == "SomeStruct *");
|
REQUIRE(NAMEOF_TYPE_T(SomeStruct *) == "SomeStruct *");
|
||||||
|
@ -304,9 +334,9 @@ TEST_CASE("NAMEOF_TYPE_T") {
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE_T(Color) == "Color");
|
REQUIRE(NAMEOF_TYPE_T(Color) == "Color");
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
REQUIRE(NAMEOF_TYPE_T(decltype(structvar)) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE_T(decltype(struct_var)) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE_T(decltype(ptrvar)) == "SomeStruct *");
|
REQUIRE(NAMEOF_TYPE_T(decltype(ptr_s)) == "SomeStruct *");
|
||||||
REQUIRE(NAMEOF_TYPE_T(decltype(refvar)) == "SomeStruct &");
|
REQUIRE(NAMEOF_TYPE_T(decltype(ref_s)) == "SomeStruct &");
|
||||||
REQUIRE(NAMEOF_TYPE_T(SomeStruct) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE_T(SomeStruct) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE_T(SomeStruct *) == "SomeStruct *");
|
REQUIRE(NAMEOF_TYPE_T(SomeStruct *) == "SomeStruct *");
|
||||||
REQUIRE(NAMEOF_TYPE_T(SomeStruct &) == "SomeStruct &");
|
REQUIRE(NAMEOF_TYPE_T(SomeStruct &) == "SomeStruct &");
|
||||||
|
@ -321,8 +351,8 @@ TEST_CASE("NAMEOF_TYPE_T") {
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE_T(Color) == "Color");
|
REQUIRE(NAMEOF_TYPE_T(Color) == "Color");
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
REQUIRE(NAMEOF_TYPE_T(decltype(structvar)) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE_T(decltype(struct_var)) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE_T(decltype(ptrvar)) == "SomeStruct*");
|
REQUIRE(NAMEOF_TYPE_T(decltype(ptr_s)) == "SomeStruct*");
|
||||||
REQUIRE(NAMEOF_TYPE_T(decltype(refvar)) == "SomeStruct&");
|
REQUIRE(NAMEOF_TYPE_T(decltype(refvar)) == "SomeStruct&");
|
||||||
REQUIRE(NAMEOF_TYPE_T(SomeStruct) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE_T(SomeStruct) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE_T(SomeStruct *) == "SomeStruct*");
|
REQUIRE(NAMEOF_TYPE_T(SomeStruct *) == "SomeStruct*");
|
||||||
|
@ -342,20 +372,20 @@ TEST_CASE("NAMEOF_TYPE_T") {
|
||||||
|
|
||||||
TEST_CASE("Spaces and Tabs ignored") {
|
TEST_CASE("Spaces and Tabs ignored") {
|
||||||
SECTION("Spaces") {
|
SECTION("Spaces") {
|
||||||
REQUIRE(NAMEOF( structvar ) == "structvar");
|
REQUIRE(NAMEOF( struct_var ) == "struct_var");
|
||||||
REQUIRE(NAMEOF_FULL( structvar ) == "structvar");
|
REQUIRE(NAMEOF_FULL( struct_var ) == "struct_var");
|
||||||
REQUIRE(NAMEOF_RAW( structvar ) == "structvar");
|
REQUIRE(NAMEOF_RAW( struct_var ) == "struct_var");
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE( structvar ) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE( struct_var ) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE_T( decltype(structvar) ) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE_T( decltype(struct_var) ) == "SomeStruct");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Tabs") {
|
SECTION("Tabs") {
|
||||||
REQUIRE(NAMEOF( structvar ) == "structvar");
|
REQUIRE(NAMEOF( struct_var ) == "struct_var");
|
||||||
REQUIRE(NAMEOF_FULL( structvar ) == "structvar");
|
REQUIRE(NAMEOF_FULL( struct_var ) == "struct_var");
|
||||||
REQUIRE(NAMEOF_RAW( structvar ) == "structvar");
|
REQUIRE(NAMEOF_RAW( struct_var ) == "struct_var");
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE( structvar ) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE( struct_var ) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE_T( decltype(structvar) ) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE_T( decltype(struct_var) ) == "SomeStruct");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue