|
3 | 3 |
|
4 | 4 | #include "ylt/reflection/member_value.hpp"
|
5 | 5 | #include "ylt/reflection/private_visitor.hpp"
|
| 6 | +#include "ylt/reflection/template_string.hpp" |
6 | 7 | #include "ylt/reflection/template_switch.hpp"
|
7 | 8 | #include "ylt/reflection/user_reflect_macro.hpp"
|
8 | 9 |
|
@@ -465,6 +466,62 @@ TEST_CASE("test visit private") {
|
465 | 466 | auto name = bank.*(std::get<1>(tp)); // ok
|
466 | 467 | }
|
467 | 468 |
|
| 469 | +namespace test_type_string { |
| 470 | +struct struct_test {}; |
| 471 | +class class_test {}; |
| 472 | +union union_test {}; |
| 473 | +} // namespace test_type_string |
| 474 | + |
| 475 | +TEST_CASE("test type_string") { |
| 476 | + CHECK(type_string<int>() == "int"); |
| 477 | + CHECK(type_string<const int>() == "const int"); |
| 478 | + CHECK(type_string<volatile int>() == "volatile int"); |
| 479 | + |
| 480 | +#if defined(__clang__) |
| 481 | + CHECK(type_string<int&>() == "int &"); |
| 482 | + CHECK(type_string<int&&>() == "int &&"); |
| 483 | + CHECK(type_string<const int&>() == "const int &"); |
| 484 | + CHECK(type_string<const int&&>() == "const int &&"); |
| 485 | + CHECK(type_string<volatile int&>() == "volatile int &"); |
| 486 | + CHECK(type_string<volatile int&&>() == "volatile int &&"); |
| 487 | +#else |
| 488 | + CHECK(type_string<int&>() == "int&"); |
| 489 | + CHECK(type_string<int&&>() == "int&&"); |
| 490 | + CHECK(type_string<const int&>() == "const int&"); |
| 491 | + CHECK(type_string<const int&&>() == "const int&&"); |
| 492 | + CHECK(type_string<volatile int&>() == "volatile int&"); |
| 493 | + CHECK(type_string<volatile int&&>() == "volatile int&&"); |
| 494 | +#endif |
| 495 | + |
| 496 | +#if defined(_MSC_VER) && !defined(__clang__) |
| 497 | + CHECK(type_string<test_type_string::struct_test>() == |
| 498 | + "struct test_type_string::struct_test"); |
| 499 | + CHECK(type_string<const test_type_string::struct_test>() == |
| 500 | + "const struct test_type_string::struct_test"); |
| 501 | + CHECK(type_string<test_type_string::class_test>() == |
| 502 | + "class test_type_string::class_test"); |
| 503 | + CHECK(type_string<const test_type_string::class_test>() == |
| 504 | + "const class test_type_string::class_test"); |
| 505 | + CHECK(type_string<test_type_string::union_test>() == |
| 506 | + "union test_type_string::union_test"); |
| 507 | + CHECK(type_string<const test_type_string::union_test>() == |
| 508 | + "const union test_type_string::union_test"); |
| 509 | +#else |
| 510 | + CHECK(type_string<test_type_string::struct_test>() == |
| 511 | + "test_type_string::struct_test"); |
| 512 | + CHECK(type_string<const test_type_string::struct_test>() == |
| 513 | + "const test_type_string::struct_test"); |
| 514 | + CHECK(type_string<test_type_string::class_test>() == |
| 515 | + "test_type_string::class_test"); |
| 516 | + CHECK(type_string<const test_type_string::class_test>() == |
| 517 | + "const test_type_string::class_test"); |
| 518 | + CHECK(type_string<test_type_string::union_test>() == |
| 519 | + "test_type_string::union_test"); |
| 520 | + CHECK(type_string<const test_type_string::union_test>() == |
| 521 | + "const test_type_string::union_test"); |
| 522 | +#endif |
| 523 | +} |
| 524 | + |
468 | 525 | DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4007)
|
469 | 526 | int main(int argc, char** argv) { return doctest::Context(argc, argv).run(); }
|
470 | 527 | DOCTEST_MSVC_SUPPRESS_WARNING_POP
|
0 commit comments