diff options
| author | Martin Hořeňovský | 2022-11-20 11:06:45 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2022-11-20 17:07:32 +0100 |
| commit | 291c502f6676b8d304b608f936ec26e3b347054a (patch) | |
| tree | 24e4a01f886a77ca8a847c5f3ca37e9fde289609 /tests/SelfTest/UsageTests/Compilation.tests.cpp | |
| parent | ae1644e7e92b09055af18c4a2d5bc9a027eb16a1 (diff) | |
| download | catch3-291c502f6676b8d304b608f936ec26e3b347054a.tar.gz | |
Fix old GCC + types with ambiguous constructor from 0
Closes #2571
Diffstat (limited to 'tests/SelfTest/UsageTests/Compilation.tests.cpp')
| -rw-r--r-- | tests/SelfTest/UsageTests/Compilation.tests.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/SelfTest/UsageTests/Compilation.tests.cpp b/tests/SelfTest/UsageTests/Compilation.tests.cpp index a61a9674..a7b32df9 100644 --- a/tests/SelfTest/UsageTests/Compilation.tests.cpp +++ b/tests/SelfTest/UsageTests/Compilation.tests.cpp @@ -329,3 +329,29 @@ TEST_CASE( "#2555 - types that can only be compared with 0 literal (not int/long REQUIRE( TypeWithLit0Comparisons{} != 0 ); REQUIRE_FALSE( 0 != TypeWithLit0Comparisons{} ); } + +namespace { + struct MultipleImplicitConstructors { + MultipleImplicitConstructors( double ) {} + MultipleImplicitConstructors( int64_t ) {} + + bool operator==( MultipleImplicitConstructors ) const { return true; } + bool operator!=( MultipleImplicitConstructors ) const { return true; } + bool operator<( MultipleImplicitConstructors ) const { return true; } + bool operator<=( MultipleImplicitConstructors ) const { return true; } + bool operator>( MultipleImplicitConstructors ) const { return true; } + bool operator>=( MultipleImplicitConstructors ) const { return true; } + }; +} + +TEST_CASE("#2571 - tests compile types that have multiple implicit constructors from lit 0", + "[compilation][approvals]") { + MultipleImplicitConstructors mic1( 0.0 ); + MultipleImplicitConstructors mic2( 0.0 ); + REQUIRE( mic1 == mic2 ); + REQUIRE( mic1 != mic2 ); + REQUIRE( mic1 < mic2 ); + REQUIRE( mic1 <= mic2 ); + REQUIRE( mic1 > mic2 ); + REQUIRE( mic1 >= mic2 ); +} |