11#include < stdx/type_traits.hpp>
22
3+ #include < catch2/catch_template_test_macros.hpp>
34#include < catch2/catch_test_macros.hpp>
45
56#include < type_traits>
@@ -25,8 +26,18 @@ TEST_CASE("to_underlying values", "[type_traits]") {
2526 CHECK (stdx::to_underlying (ScopedEnum::Value5) == 5 );
2627}
2728
28- TEST_CASE (" to_underlying works on integral types" , " [type_traits]" ) {
29- constexpr int x = 0 ;
30- CHECK (std::is_same_v<decltype (stdx::to_underlying (x)), int >);
31- CHECK (stdx::to_underlying (x) == 0 );
29+ TEMPLATE_TEST_CASE (" to_underlying works on integral types" , " [type_traits]" ,
30+ bool , char , signed char , unsigned char , short int ,
31+ unsigned short int , int , unsigned int , long int ,
32+ unsigned long int ) {
33+ constexpr TestType x{};
34+ CHECK (std::is_same_v<decltype (stdx::to_underlying (x)), TestType>);
35+ CHECK (stdx::to_underlying (x) == TestType{});
36+ }
37+
38+ TEMPLATE_TEST_CASE (" to_underlying works on floating point types" ,
39+ " [type_traits]" , float , double ) {
40+ constexpr TestType x{};
41+ CHECK (std::is_same_v<decltype (stdx::to_underlying (x)), TestType>);
42+ CHECK (stdx::to_underlying (x) == TestType{});
3243}
0 commit comments