mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Add CaseInsensitiveEqualTo comparison type
This commit is contained in:
@@ -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" ) );
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user