This commit is contained in:
Neargye 2018-05-04 00:46:41 +05:00
parent 0150c2f247
commit edbd61ad42
2 changed files with 12 additions and 24 deletions

View file

@ -49,17 +49,15 @@ struct Long {
LL ll; LL ll;
}; };
int somevar;
enum class Color { RED, GREEN, BLUE }; enum class Color { RED, GREEN, BLUE };
int main() { SomeStruct somevar;
SomeStruct somevar; Long othervar;
Long othervar; int intvar;
int intvar; SomeStruct* ptrvar;
SomeStruct* ptrvar; SomeStruct** ptrptrvar;
SomeStruct** ptrptrvar;
int main() {
// constexpr // constexpr
constexpr auto constexpr_work_fine = NAMEOF(intvar); constexpr auto constexpr_work_fine = NAMEOF(intvar);
std::cout << constexpr_work_fine << std::endl; // intvar std::cout << constexpr_work_fine << std::endl; // intvar

View file

@ -53,13 +53,15 @@ struct Long {
LL ll; LL ll;
}; };
int somevar;
enum class Color { RED, GREEN, BLUE }; enum class Color { RED, GREEN, BLUE };
TEST_CASE("constexpr") { SomeStruct somevar;
SomeStruct somevar; Long othervar;
int intvar;
SomeStruct* ptrvar;
SomeStruct** ptrptrvar;
TEST_CASE("constexpr") {
SECTION("NAMEOF") { SECTION("NAMEOF") {
// variable // variable
constexpr auto cx1 = NAMEOF((&somevar)->somefield); constexpr auto cx1 = NAMEOF((&somevar)->somefield);
@ -98,12 +100,6 @@ TEST_CASE("constexpr") {
} }
TEST_CASE("NAMEOF") { TEST_CASE("NAMEOF") {
SomeStruct somevar;
Long othervar;
int intvar;
SomeStruct* ptrvar;
SomeStruct** ptrptrvar;
SECTION("variable") { SECTION("variable") {
REQUIRE(std::strcmp(NAMEOF(somevar), "somevar") == 0); REQUIRE(std::strcmp(NAMEOF(somevar), "somevar") == 0);
REQUIRE(std::strcmp(NAMEOF(&somevar), "somevar") == 0); REQUIRE(std::strcmp(NAMEOF(&somevar), "somevar") == 0);
@ -156,12 +152,6 @@ TEST_CASE("NAMEOF") {
} }
TEST_CASE("NAMEOF_FULL") { TEST_CASE("NAMEOF_FULL") {
SomeStruct somevar;
Long othervar;
int intvar;
SomeStruct* ptrvar;
SomeStruct** ptrptrvar;
SECTION("variable") { SECTION("variable") {
REQUIRE(std::strcmp(NAMEOF_FULL(somevar), "somevar") == 0); REQUIRE(std::strcmp(NAMEOF_FULL(somevar), "somevar") == 0);
REQUIRE(std::strcmp(NAMEOF_FULL(&somevar), "&somevar") == 0); REQUIRE(std::strcmp(NAMEOF_FULL(&somevar), "&somevar") == 0);