diff options
| author | Martin Hořeňovský | 2021-12-26 18:54:47 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2021-12-26 18:54:47 +0100 |
| commit | cbb6764fb1c22bbd283ea7af6a69d012c470ec58 (patch) | |
| tree | 962683bdd786ac4437818468f77f008c6440d87c /tests/SelfTest/IntrospectiveTests | |
| parent | 156e6fdfa9122ea9b52fe6e65f20c66cf38688a7 (diff) | |
| download | catch3-cbb6764fb1c22bbd283ea7af6a69d012c470ec58.tar.gz | |
Add CaseInsensitiveEqualTo comparison type
Diffstat (limited to 'tests/SelfTest/IntrospectiveTests')
| -rw-r--r-- | tests/SelfTest/IntrospectiveTests/Details.tests.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/SelfTest/IntrospectiveTests/Details.tests.cpp b/tests/SelfTest/IntrospectiveTests/Details.tests.cpp index bddb0d5b..38adcbac 100644 --- a/tests/SelfTest/IntrospectiveTests/Details.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/Details.tests.cpp @@ -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" ) ); + } +} |