-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathct_conversions.cpp
More file actions
46 lines (35 loc) · 1.33 KB
/
ct_conversions.cpp
File metadata and controls
46 lines (35 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdx/ct_conversions.hpp>
#include <catch2/catch_test_macros.hpp>
#include <string_view>
struct complete {};
struct incomplete;
TEST_CASE("type as string", "[ct_conversion]") {
using namespace std::string_view_literals;
STATIC_REQUIRE(stdx::type_as_string<int>() == "int"sv);
STATIC_REQUIRE(stdx::type_as_string<complete>() == "complete"sv);
STATIC_REQUIRE(stdx::type_as_string<incomplete>() == "incomplete"sv);
}
template <typename T> struct type_template;
template <auto T> struct value_template;
TEST_CASE("template base", "[ct_conversion]") {
using namespace std::string_view_literals;
STATIC_REQUIRE(stdx::template_base<type_template<int>>() ==
"type_template"sv);
STATIC_REQUIRE(stdx::template_base<value_template<42>>() ==
"value_template"sv);
STATIC_REQUIRE(stdx::template_base<int>() == "int"sv);
}
namespace {
enum A { X };
enum struct B { Y };
} // namespace
TEST_CASE("enum as string", "[ct_conversion]") {
using namespace std::string_view_literals;
STATIC_CHECK(stdx::enum_as_string<X>() == "X"sv);
STATIC_CHECK(stdx::enum_as_string<B::Y>() == "Y"sv);
}
enum struct C {};
TEST_CASE("enum as string (no identifier)", "[ct_conversion]") {
using namespace std::string_view_literals;
STATIC_CHECK(stdx::enum_as_string<C{17}>() == "(C)17"sv);
}