Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions test/to_underlying.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <stdx/type_traits.hpp>

#include <catch2/catch_template_test_macros.hpp>
#include <catch2/catch_test_macros.hpp>

#include <type_traits>
Expand All @@ -25,8 +26,18 @@ TEST_CASE("to_underlying values", "[type_traits]") {
CHECK(stdx::to_underlying(ScopedEnum::Value5) == 5);
}

TEST_CASE("to_underlying works on integral types", "[type_traits]") {
constexpr int x = 0;
CHECK(std::is_same_v<decltype(stdx::to_underlying(x)), int>);
CHECK(stdx::to_underlying(x) == 0);
TEMPLATE_TEST_CASE("to_underlying works on integral types", "[type_traits]",
bool, char, signed char, unsigned char, short int,
unsigned short int, int, unsigned int, long int,
unsigned long int) {
constexpr TestType x{};
CHECK(std::is_same_v<decltype(stdx::to_underlying(x)), TestType>);
CHECK(stdx::to_underlying(x) == TestType{});
}

TEMPLATE_TEST_CASE("to_underlying works on floating point types",
"[type_traits]", float, double) {
constexpr TestType x{};
CHECK(std::is_same_v<decltype(stdx::to_underlying(x)), TestType>);
CHECK(stdx::to_underlying(x) == TestType{});
}