add more test
This commit is contained in:
parent
89cafe2797
commit
2de92d9504
1 changed files with 281 additions and 111 deletions
352
test/test.cpp
352
test/test.cpp
|
@ -50,7 +50,7 @@ template <typename T>
|
||||||
class SomeClass {
|
class SomeClass {
|
||||||
public:
|
public:
|
||||||
void SomeMethod5() const {
|
void SomeMethod5() const {
|
||||||
std::cout << nameof::NameofType<T>() << std::endl;
|
std::cout << NAMEOF_TYPE_T(T) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename C>
|
template <typename C>
|
||||||
|
@ -70,36 +70,50 @@ struct Long {
|
||||||
|
|
||||||
enum class Color { RED, GREEN, BLUE };
|
enum class Color { RED, GREEN, BLUE };
|
||||||
|
|
||||||
SomeStruct somevar;
|
SomeStruct structvar;
|
||||||
Long othervar;
|
Long othervar;
|
||||||
SomeStruct& refvar = somevar;
|
SomeStruct * ptrvar = &structvar;
|
||||||
SomeStruct* ptrvar = &somevar;
|
SomeStruct & refvar = structvar;
|
||||||
|
const SomeClass<int> volatile * classvar;
|
||||||
|
|
||||||
#if NAMEOF_HAS_CONSTEXPR
|
|
||||||
// Compile-time nameof supported by C++14.
|
|
||||||
TEST_CASE("constexpr") {
|
TEST_CASE("constexpr") {
|
||||||
SECTION("NAMEOF") {
|
SECTION("NAMEOF") {
|
||||||
// variable
|
// variable
|
||||||
constexpr auto cx1 = NAMEOF(somevar);
|
constexpr auto cx1 = NAMEOF(structvar);
|
||||||
static_assert(cx1 == "somevar", "");
|
static_assert(cx1 == "structvar", "");
|
||||||
// member
|
// member
|
||||||
constexpr auto cx2 = NAMEOF((&somevar)->somefield);
|
constexpr auto cx2 = NAMEOF((&structvar)->somefield);
|
||||||
static_assert(cx2 == "somefield", "");
|
static_assert(cx2 == "somefield", "");
|
||||||
// function
|
// function
|
||||||
constexpr auto cx3 = NAMEOF(&SomeStruct::SomeMethod2);
|
constexpr auto cx3 = NAMEOF(&SomeClass<int>::SomeMethod6<long int>);
|
||||||
static_assert(cx3 == "SomeMethod2", "");
|
static_assert(cx3 == "SomeMethod6", "");
|
||||||
// enum
|
// enum
|
||||||
constexpr auto cx4 = NAMEOF(Color::RED);
|
constexpr auto cx4 = NAMEOF(Color::RED);
|
||||||
static_assert(cx4 == "RED", "");
|
static_assert(cx4 == "RED", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("NAMEOF_FULL") {
|
||||||
|
// variable
|
||||||
|
constexpr auto cx1 = NAMEOF_FULL(structvar);
|
||||||
|
static_assert(cx1 == "structvar", "");
|
||||||
|
// member
|
||||||
|
constexpr auto cx2 = NAMEOF_FULL((&structvar)->somefield);
|
||||||
|
static_assert(cx2 == "somefield", "");
|
||||||
|
// function
|
||||||
|
constexpr auto cx3 = NAMEOF_FULL(&SomeClass<int>::SomeMethod6<long int>);
|
||||||
|
static_assert(cx3 == "SomeMethod6<long int>", "");
|
||||||
|
// enum
|
||||||
|
constexpr auto cx4 = NAMEOF_FULL(Color::RED);
|
||||||
|
static_assert(cx4 == "RED", "");
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("NAMEOF_RAW") {
|
SECTION("NAMEOF_RAW") {
|
||||||
// variable
|
// variable
|
||||||
constexpr auto cx1 = NAMEOF_RAW(somevar);
|
constexpr auto cx1 = NAMEOF_RAW(structvar);
|
||||||
static_assert(cx1 == "somevar", "");
|
static_assert(cx1 == "structvar", "");
|
||||||
// member
|
// member
|
||||||
constexpr auto cx2 = NAMEOF_RAW((&somevar)->somefield);
|
constexpr auto cx2 = NAMEOF_RAW((&structvar)->somefield);
|
||||||
static_assert(cx2 == "(&somevar)->somefield", "");
|
static_assert(cx2 == "(&structvar)->somefield", "");
|
||||||
// type
|
// type
|
||||||
constexpr auto cx3 = NAMEOF_RAW(std::string);
|
constexpr auto cx3 = NAMEOF_RAW(std::string);
|
||||||
static_assert(cx3 == "std::string", "");
|
static_assert(cx3 == "std::string", "");
|
||||||
|
@ -114,51 +128,57 @@ TEST_CASE("constexpr") {
|
||||||
static_assert(cx6 == "__cplusplus", "");
|
static_assert(cx6 == "__cplusplus", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// constexpr in NAMEOF_TYPE not supported if GCC.
|
||||||
#if defined(_MSC_VER) || defined(__clang__)
|
#if defined(_MSC_VER) || defined(__clang__)
|
||||||
SECTION("NAMEOF_TYPE") {
|
SECTION("NAMEOF_TYPE") {
|
||||||
SomeClass<int> a;
|
constexpr auto cx = NAMEOF_TYPE(classvar);
|
||||||
|
static_assert(cx == "SomeClass", "");
|
||||||
constexpr auto cx1 = NAMEOF_TYPE(a);
|
}
|
||||||
constexpr auto cx2 = nameof::NameofType<SomeClass<int>>();
|
|
||||||
constexpr auto cx3 = nameof::NameofType<decltype(a)>();
|
SECTION("NAMEOF_TYPE") {
|
||||||
|
constexpr auto cx = NAMEOF_TYPE_T(const SomeClass<int> volatile *);
|
||||||
|
static_assert(cx == "SomeClass", "");
|
||||||
static_assert(cx1 == "SomeClass", "");
|
}
|
||||||
static_assert(cx2 == "SomeClass", "");
|
|
||||||
static_assert(cx3 == "SomeClass", "");
|
SECTION("NAMEOF_TYPE_FULL") {
|
||||||
|
constexpr auto cx = NAMEOF_TYPE_FULL(classvar);
|
||||||
|
static_assert(cx == "SomeClass<int>", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("NAMEOF_TYPE_FULL") {
|
||||||
|
constexpr auto cx = NAMEOF_TYPE_FULL_T(const SomeClass<int> volatile *);
|
||||||
|
static_assert(cx == "SomeClass<int>", "");
|
||||||
}
|
}
|
||||||
# endif
|
|
||||||
|
|
||||||
SECTION("NAMEOF_TYPE_RAW") {
|
SECTION("NAMEOF_TYPE_RAW") {
|
||||||
SomeClass<int> a;
|
constexpr auto cx = NAMEOF_TYPE_RAW(classvar);
|
||||||
|
#if defined(__clang__)
|
||||||
constexpr auto cx1 = NAMEOF_TYPE_RAW(a);
|
static_assert(cx == "const volatile SomeClass<int> *", "");
|
||||||
constexpr auto cx2 = nameof::NameofTypeRaw<SomeClass<int>>();
|
#elif defined(_MSC_VER)
|
||||||
constexpr auto cx3 = nameof::NameofTypeRaw<decltype(a)>();
|
static_assert(cx == "SomeClass<int> const volatile *", "");
|
||||||
|
|
||||||
# if defined(_MSC_VER)
|
|
||||||
static_assert(cx1 == "class SomeClass<int>", "");
|
|
||||||
static_assert(cx2 == "class SomeClass<int>", "");
|
|
||||||
static_assert(cx3 == "class SomeClass<int>", "");
|
|
||||||
# elif defined(__clang__)
|
|
||||||
static_assert(cx1 == "SomeClass<int>", "");
|
|
||||||
static_assert(cx2 == "SomeClass<int>", "");
|
|
||||||
static_assert(cx3 == "SomeClass<int>", "");
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
SECTION("NAMEOF_TYPE_RAW") {
|
||||||
|
constexpr auto cx = NAMEOF_TYPE_RAW_T(const SomeClass<int> volatile *);
|
||||||
|
#if defined(__clang__)
|
||||||
|
static_assert(cx == "const volatile SomeClass<int> *", "");
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
static_assert(cx == "SomeClass<int> const volatile *", "");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("simple name") {
|
TEST_CASE("NAMEOF") {
|
||||||
SECTION("variable") {
|
SECTION("variable") {
|
||||||
REQUIRE(NAMEOF(somevar) == "somevar");
|
REQUIRE(NAMEOF(structvar) == "structvar");
|
||||||
REQUIRE(NAMEOF(::somevar) == "somevar");
|
REQUIRE(NAMEOF(::structvar) == "structvar");
|
||||||
REQUIRE(NAMEOF(ptrvar) == "ptrvar");
|
REQUIRE(NAMEOF(ptrvar) == "ptrvar");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("member") {
|
SECTION("member") {
|
||||||
REQUIRE(NAMEOF(somevar.somefield) == "somefield");
|
REQUIRE(NAMEOF(structvar.somefield) == "somefield");
|
||||||
REQUIRE(NAMEOF((&somevar)->somefield) == "somefield");
|
REQUIRE(NAMEOF((&structvar)->somefield) == "somefield");
|
||||||
REQUIRE(NAMEOF(othervar.ll.field) == "field");
|
REQUIRE(NAMEOF(othervar.ll.field) == "field");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,22 +197,51 @@ TEST_CASE("simple name") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("raw name") {
|
TEST_CASE("NAMEOF_FULL") {
|
||||||
SECTION("variable") {
|
SECTION("variable") {
|
||||||
REQUIRE(NAMEOF_RAW(somevar) == "somevar");
|
REQUIRE(NAMEOF_FULL(structvar) == "structvar");
|
||||||
REQUIRE(NAMEOF_RAW(&somevar) == "&somevar");
|
REQUIRE(NAMEOF_FULL(::structvar) == "structvar");
|
||||||
REQUIRE(NAMEOF_RAW(::somevar) == "::somevar");
|
REQUIRE(NAMEOF_FULL(ptrvar) == "ptrvar");
|
||||||
REQUIRE(NAMEOF_RAW(ptrvar) == "ptrvar");
|
|
||||||
REQUIRE(NAMEOF_RAW(*ptrvar) == "*ptrvar");
|
|
||||||
REQUIRE(NAMEOF_RAW(+somevar.somefield) == "+somevar.somefield");
|
|
||||||
REQUIRE(NAMEOF_RAW(-somevar.somefield) == "-somevar.somefield");
|
|
||||||
REQUIRE(NAMEOF_RAW(~somevar.somefield) == "~somevar.somefield");
|
|
||||||
REQUIRE(NAMEOF_RAW(!somevar.somefield) == "!somevar.somefield");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("member") {
|
SECTION("member") {
|
||||||
REQUIRE(NAMEOF_RAW(somevar.somefield) == "somevar.somefield");
|
REQUIRE(NAMEOF_FULL(structvar.somefield) == "somefield");
|
||||||
REQUIRE(NAMEOF_RAW((&somevar)->somefield) == "(&somevar)->somefield");
|
REQUIRE(NAMEOF_FULL((&structvar)->somefield) == "somefield");
|
||||||
|
REQUIRE(NAMEOF_FULL(othervar.ll.field) == "field");
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("function") {
|
||||||
|
REQUIRE(NAMEOF_FULL(&SomeStruct::SomeMethod1) == "SomeMethod1");
|
||||||
|
REQUIRE(NAMEOF_FULL(&SomeStruct::SomeMethod2) == "SomeMethod2");
|
||||||
|
REQUIRE(NAMEOF_FULL(SomeMethod3) == "SomeMethod3");
|
||||||
|
REQUIRE(NAMEOF_FULL(SomeMethod4<int>) == "SomeMethod4<int>");
|
||||||
|
REQUIRE(NAMEOF_FULL(&SomeClass<int>::SomeMethod5) == "SomeMethod5");
|
||||||
|
REQUIRE(NAMEOF_FULL(&SomeClass<int>::SomeMethod6<long int>) == "SomeMethod6<long int>");
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("enum") {
|
||||||
|
REQUIRE(NAMEOF_FULL(Color::RED) == "RED");
|
||||||
|
REQUIRE(NAMEOF_FULL(Color::BLUE) == "BLUE");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("NAMEOF_RAW") {
|
||||||
|
SECTION("variable") {
|
||||||
|
REQUIRE(NAMEOF_RAW(structvar) == "structvar");
|
||||||
|
REQUIRE(NAMEOF_RAW(&structvar) == "&structvar");
|
||||||
|
REQUIRE(NAMEOF_RAW(::structvar) == "::structvar");
|
||||||
|
REQUIRE(NAMEOF_RAW(ptrvar) == "ptrvar");
|
||||||
|
REQUIRE(NAMEOF_RAW(*ptrvar) == "*ptrvar");
|
||||||
|
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) == "!structvar.somefield");
|
||||||
|
REQUIRE(NAMEOF_RAW(structvar.somefield + refvar.somefield) == "structvar.somefield + refvar.somefield");
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("member") {
|
||||||
|
REQUIRE(NAMEOF_RAW(structvar.somefield) == "structvar.somefield");
|
||||||
|
REQUIRE(NAMEOF_RAW((&structvar)->somefield) == "(&structvar)->somefield");
|
||||||
REQUIRE(NAMEOF_RAW(othervar.ll.field) == "othervar.ll.field");
|
REQUIRE(NAMEOF_RAW(othervar.ll.field) == "othervar.ll.field");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,40 +273,86 @@ TEST_CASE("raw name") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("type name") {
|
TEST_CASE("NAMEOF_TYPE") {
|
||||||
REQUIRE(NAMEOF_TYPE(somevar) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE(structvar) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE(ptrvar) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE(ptrvar) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE(refvar) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE(refvar) == "SomeStruct");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE(classvar) == "SomeClass");
|
||||||
|
REQUIRE(NAMEOF_TYPE(std::declval<const SomeClass<int> volatile *>()) == "SomeClass");
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE(othervar) == "Long");
|
REQUIRE(NAMEOF_TYPE(othervar) == "Long");
|
||||||
REQUIRE(NAMEOF_TYPE(othervar.ll) == "LL");
|
REQUIRE(NAMEOF_TYPE(othervar.ll) == "LL");
|
||||||
REQUIRE(NAMEOF_TYPE(othervar.ll.field) == "int");
|
REQUIRE(NAMEOF_TYPE(othervar.ll.field) == "int");
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE(Color::RED) == "Color");
|
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE(std::string{}) == "basic_string");
|
REQUIRE(NAMEOF_TYPE(std::string{}) == "basic_string");
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE(std::declval<const SomeClass<int>>()) == "SomeClass");
|
REQUIRE(NAMEOF_TYPE(Color::RED) == "Color");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("type raw name") {
|
TEST_CASE("NAMEOF_TYPE_T") {
|
||||||
#if defined(_MSC_VER)
|
REQUIRE(NAMEOF_TYPE_T(decltype(structvar)) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(somevar) == "struct SomeStruct");
|
REQUIRE(NAMEOF_TYPE_T(decltype(ptrvar)) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(ptrvar) == "structSomeStruct*");
|
REQUIRE(NAMEOF_TYPE_T(decltype(refvar)) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(refvar) == "structSomeStruct&");
|
REQUIRE(NAMEOF_TYPE_T(SomeStruct) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_T(SomeStruct *) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_T(SomeStruct &) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_T(const SomeStruct volatile *) == "SomeStruct");
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(othervar) == "struct Long");
|
REQUIRE(NAMEOF_TYPE_T(SomeClass<int>) == "SomeClass");
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(othervar.ll) == "struct Long::LL");
|
REQUIRE(NAMEOF_TYPE_T(const SomeClass<int> volatile *) == "SomeClass");
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(othervar.ll.field) == "int");
|
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(Color::RED) == "enum Color");
|
REQUIRE(NAMEOF_TYPE_T(decltype(othervar)) == "Long");
|
||||||
|
REQUIRE(NAMEOF_TYPE_T(Long) == "Long");
|
||||||
|
REQUIRE(NAMEOF_TYPE_T(Long::LL) == "LL");
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(std::declval<const SomeClass<int>>()) == "const classSomeClass<int>&&");
|
REQUIRE(NAMEOF_TYPE_T(std::string) == "basic_string");
|
||||||
#elif defined(__clang__)
|
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(somevar) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE_T(Color) == "Color");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("NAMEOF_TYPE_FULL") {
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL(structvar) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL(ptrvar) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL(refvar) == "SomeStruct");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL(classvar) == "SomeClass<int>");
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL(std::declval<const SomeClass<int> volatile *>()) == "SomeClass<int>");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL(othervar) == "Long");
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL(othervar.ll) == "LL");
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL(othervar.ll.field) == "int");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL(Color::RED) == "Color");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("NAMEOF_TYPE_FULL_T") {
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL_T(decltype(structvar)) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL_T(decltype(ptrvar)) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL_T(decltype(refvar)) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL_T(SomeStruct) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL_T(SomeStruct *) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL_T(SomeStruct &) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL_T(const SomeStruct volatile *) == "SomeStruct");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL_T(SomeClass<int>) == "SomeClass<int>");
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL_T(const SomeClass<int> volatile *) == "SomeClass<int>");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL_T(decltype(othervar)) == "Long");
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL_T(Long) == "Long");
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL_T(Long::LL) == "LL");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_FULL_T(Color) == "Color");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("NAMEOF_TYPE_RAW") {
|
||||||
|
#if defined(__clang__)
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW(structvar) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(ptrvar) == "SomeStruct *");
|
REQUIRE(NAMEOF_TYPE_RAW(ptrvar) == "SomeStruct *");
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(refvar) == "SomeStruct &");
|
REQUIRE(NAMEOF_TYPE_RAW(refvar) == "SomeStruct &");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW(classvar) == "const volatile SomeClass<int> *");
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(othervar) == "Long");
|
REQUIRE(NAMEOF_TYPE_RAW(othervar) == "Long");
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(othervar.ll) == "Long::LL");
|
REQUIRE(NAMEOF_TYPE_RAW(othervar.ll) == "Long::LL");
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(othervar.ll.field) == "int");
|
REQUIRE(NAMEOF_TYPE_RAW(othervar.ll.field) == "int");
|
||||||
|
@ -265,11 +360,27 @@ TEST_CASE("type raw name") {
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(Color::RED) == "Color");
|
REQUIRE(NAMEOF_TYPE_RAW(Color::RED) == "Color");
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(std::declval<const SomeClass<int>>()) == "const SomeClass<int> &&");
|
REQUIRE(NAMEOF_TYPE_RAW(std::declval<const SomeClass<int>>()) == "const SomeClass<int> &&");
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW(structvar) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW(ptrvar) == "SomeStruct *");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW(refvar) == "SomeStruct &");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW(classvar) == "SomeClass<int> const volatile *");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW(othervar) == "Long");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW(othervar.ll) == "Long::LL");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW(othervar.ll.field) == "int");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW(Color::RED) == "Color");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW(std::declval<const SomeClass<int>>()) == "SomeClass<int> const &&");
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(somevar) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE_RAW(structvar) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(ptrvar) == "SomeStruct*");
|
REQUIRE(NAMEOF_TYPE_RAW(ptrvar) == "SomeStruct*");
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(refvar) == "SomeStruct&");
|
REQUIRE(NAMEOF_TYPE_RAW(refvar) == "SomeStruct&");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW(classvar) == "const volatile SomeClass<int>*");
|
||||||
|
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(othervar) == "Long");
|
REQUIRE(NAMEOF_TYPE_RAW(othervar) == "Long");
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(othervar.ll) == "Long::LL");
|
REQUIRE(NAMEOF_TYPE_RAW(othervar.ll) == "Long::LL");
|
||||||
REQUIRE(NAMEOF_TYPE_RAW(othervar.ll.field) == "int");
|
REQUIRE(NAMEOF_TYPE_RAW(othervar.ll.field) == "int");
|
||||||
|
@ -280,26 +391,85 @@ TEST_CASE("type raw name") {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("NAMEOF_TYPE_RAW_T") {
|
||||||
|
#if defined(__clang__)
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(decltype(structvar)) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(decltype(ptrvar)) == "SomeStruct *");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(decltype(refvar)) == "SomeStruct &");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(SomeStruct) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(SomeStruct *) == "SomeStruct *");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(SomeStruct &) == "SomeStruct &");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(const SomeStruct volatile *) == "const volatile SomeStruct *");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(SomeClass<int>) == "SomeClass<int>");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(const SomeClass<int> volatile *) == "const volatile SomeClass<int> *");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(decltype(othervar)) == "Long");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(Long) == "Long");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(Long::LL) == "Long::LL");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(Color) == "Color");
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(decltype(structvar)) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(decltype(ptrvar)) == "SomeStruct *");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(decltype(refvar)) == "SomeStruct &");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(SomeStruct) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(SomeStruct *) == "SomeStruct *");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(SomeStruct &) == "SomeStruct &");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(const SomeStruct volatile *) == "SomeStruct const volatile *");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(SomeClass<int>) == "SomeClass<int>");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(const SomeClass<int> volatile *) == "SomeClass<int> const volatile *");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(decltype(othervar)) == "Long");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(Long) == "Long");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(Long::LL) == "Long::LL");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(Color) == "Color");
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(decltype(structvar)) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(decltype(ptrvar)) == "SomeStruct*");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(decltype(refvar)) == "SomeStruct&");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(SomeStruct) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(SomeStruct *) == "SomeStruct*");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(SomeStruct &) == "SomeStruct&");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(const SomeStruct volatile *) == "const volatile SomeStruct*");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(SomeClass<int>) == "SomeClass<int>");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(const SomeClass<int> volatile *) == "const volatile SomeClass<int>*");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(decltype(othervar)) == "Long");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(Long) == "Long");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(Long::LL) == "Long::LL");
|
||||||
|
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T(Color) == "Color");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("Spaces and Tabs ignored") {
|
TEST_CASE("Spaces and Tabs ignored") {
|
||||||
SECTION("Spaces") {
|
SECTION("Spaces") {
|
||||||
REQUIRE(NAMEOF( somevar ) == "somevar");
|
REQUIRE(NAMEOF( structvar ) == "structvar");
|
||||||
REQUIRE(NAMEOF_RAW( somevar ) == "somevar");
|
REQUIRE(NAMEOF_FULL( structvar ) == "structvar");
|
||||||
REQUIRE(NAMEOF_TYPE( somevar ) == "SomeStruct");
|
REQUIRE(NAMEOF_RAW( structvar ) == "structvar");
|
||||||
#if defined(_MSC_VER)
|
|
||||||
REQUIRE(NAMEOF_TYPE_RAW( somevar ) == "struct SomeStruct");
|
REQUIRE(NAMEOF_TYPE( structvar ) == "SomeStruct");
|
||||||
#elif defined(__GNUC__) || defined(__clang__)
|
REQUIRE(NAMEOF_TYPE_T( decltype(structvar) ) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE_RAW( somevar ) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE_FULL( structvar ) == "SomeStruct");
|
||||||
#endif
|
REQUIRE(NAMEOF_TYPE_FULL_T( decltype(structvar) ) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW( structvar ) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T( decltype(structvar) ) == "SomeStruct");
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Tabs") {
|
SECTION("Tabs") {
|
||||||
REQUIRE(NAMEOF( somevar ) == "somevar");
|
REQUIRE(NAMEOF( structvar ) == "structvar");
|
||||||
REQUIRE(NAMEOF_RAW( somevar ) == "somevar");
|
REQUIRE(NAMEOF_FULL( structvar ) == "structvar");
|
||||||
REQUIRE(NAMEOF_TYPE( somevar ) == "SomeStruct");
|
REQUIRE(NAMEOF_RAW( structvar ) == "structvar");
|
||||||
#if defined(_MSC_VER)
|
|
||||||
REQUIRE(NAMEOF_TYPE_RAW( somevar ) == "struct SomeStruct");
|
REQUIRE(NAMEOF_TYPE( structvar ) == "SomeStruct");
|
||||||
#elif defined(__GNUC__) || defined(__clang__)
|
REQUIRE(NAMEOF_TYPE_T( decltype(structvar) ) == "SomeStruct");
|
||||||
REQUIRE(NAMEOF_TYPE_RAW( somevar ) == "SomeStruct");
|
REQUIRE(NAMEOF_TYPE_FULL( structvar ) == "SomeStruct");
|
||||||
#endif
|
REQUIRE(NAMEOF_TYPE_FULL_T( decltype(structvar) ) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW( structvar ) == "SomeStruct");
|
||||||
|
REQUIRE(NAMEOF_TYPE_RAW_T( decltype(structvar) ) == "SomeStruct");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue