Support sentinel-based ranges in default stringify (#2004)

This commit is contained in:
Sean Middleditch
2020-08-18 01:34:47 -07:00
committed by GitHub
parent 2b34b5c7d0
commit 284672cc84
8 changed files with 47 additions and 11 deletions

View File

@@ -4,6 +4,13 @@
enum class EnumClass3 { Value1, Value2, Value3, Value4 };
struct UsesSentinel {
using const_iterator = int const*;
using const_sentinel = std::nullptr_t;
const_iterator begin() const { return nullptr; }
const_iterator end() const { return nullptr; }
};
TEST_CASE( "parseEnums", "[Strings][enums]" ) {
using namespace Catch::Matchers;
@@ -40,3 +47,7 @@ TEST_CASE( "Directly creating an EnumInfo" ) {
CHECK( enumInfo->lookup(1) == "Value2" );
CHECK( enumInfo->lookup(3) == "{** unexpected enum value **}" );
}
TEST_CASE("Range type with sentinel") {
CHECK( Catch::Detail::stringify(UsesSentinel{}) == "{ }" );
}