Add CaseInsensitiveEqualTo comparison type

This commit is contained in:
Martin Hořeňovský
2021-12-26 18:54:47 +01:00
parent 156e6fdfa9
commit cbb6764fb1
12 changed files with 358 additions and 8 deletions

View File

@@ -5,6 +5,7 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/internal/catch_enforce.hpp>
#include <catch2/internal/catch_case_insensitive_comparisons.hpp>
#if defined(_MSC_VER)
#pragma warning(push)
@@ -22,3 +23,35 @@ TEST_CASE("Check that our error handling macros throw the right exceptions", "[!
#if defined(_MSC_VER)
#pragma warning(pop) // unreachable code in the macro expansions
#endif
TEST_CASE("CaseInsensitiveLess is case insensitive", "[comparisons][string-case]") {
Catch::Detail::CaseInsensitiveLess lt;
SECTION( "Degenerate cases" ) {
REQUIRE( lt( "", "a" ) );
REQUIRE_FALSE( lt( "a", "a" ) );
REQUIRE_FALSE( lt( "", "" ) );
}
SECTION("Plain comparisons") {
REQUIRE( lt( "a", "b" ) );
REQUIRE( lt( "a", "B" ) );
REQUIRE( lt( "A", "b" ) );
REQUIRE( lt( "A", "B" ) );
}
}
TEST_CASE( "CaseInsensitiveEqualsTo is case insensitive",
"[comparisons][string-case]" ) {
Catch::Detail::CaseInsensitiveEqualTo eq;
SECTION( "Degenerate cases" ) {
REQUIRE( eq( "", "" ) );
REQUIRE_FALSE( eq( "", "a" ) );
}
SECTION( "Plain comparisons" ) {
REQUIRE( eq( "a", "a" ) );
REQUIRE( eq( "a", "A" ) );
REQUIRE( eq( "A", "a" ) );
REQUIRE( eq( "A", "A" ) );
REQUIRE_FALSE( eq( "a", "b" ) );
REQUIRE_FALSE( eq( "a", "B" ) );
}
}