update README

This commit is contained in:
2019-11-22 06:34:53 +07:00
parent 3b47ce65e4
commit 516759f961
2 changed files with 24 additions and 22 deletions

View File

@@ -24,30 +24,30 @@ namespace
TEST_CASE("examples") {
SECTION("traits_using") {
// size
STATIC_REQUIRE(color_traits::size == 4);
static_assert(color_traits::size == 4);
// to_underlying
STATIC_REQUIRE(color_traits::to_underlying(color::white) == 0xFFFFFF);
static_assert(color_traits::to_underlying(color::white) == 0xFFFFFF);
// to_string
STATIC_REQUIRE(color_traits::to_string(color::red) == "red");
STATIC_REQUIRE(color_traits::to_string(color(42)) == std::nullopt);
static_assert(color_traits::to_string(color::red) == "red");
static_assert(color_traits::to_string(color(42)) == std::nullopt);
// from_string
STATIC_REQUIRE(color_traits::from_string("green") == color::green);
STATIC_REQUIRE(color_traits::from_string("error") == std::nullopt);
static_assert(color_traits::from_string("green") == color::green);
static_assert(color_traits::from_string("error") == std::nullopt);
// to_index
STATIC_REQUIRE(color_traits::to_index(color::blue) == 2u);
STATIC_REQUIRE(color_traits::to_index(color(42)) == std::nullopt);
static_assert(color_traits::to_index(color::blue) == 2u);
static_assert(color_traits::to_index(color(42)) == std::nullopt);
// from_index
STATIC_REQUIRE(color_traits::from_index(2) == color::blue);
STATIC_REQUIRE(color_traits::from_index(42) == std::nullopt);
static_assert(color_traits::from_index(2) == color::blue);
static_assert(color_traits::from_index(42) == std::nullopt);
// names
for ( auto n : color_traits::names ) {
std::cout << n << ",";
}
} // stdout: red,green,blue,
}
}