mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 12:17:11 +01:00 
			
		
		
		
	| @@ -12,6 +12,19 @@ namespace { namespace CompilationTests { | ||||
| #ifndef COMPILATION_TEST_HELPERS_INCLUDED // Don't compile this more than once per TU | ||||
| #define COMPILATION_TEST_HELPERS_INCLUDED | ||||
|  | ||||
|     // Comparison operators can return non-booleans. | ||||
|     // This is unusual, but should be supported. | ||||
|     struct logic_t { | ||||
|         logic_t operator< (logic_t) const { return {}; } | ||||
|         logic_t operator<=(logic_t) const { return {}; } | ||||
|         logic_t operator> (logic_t) const { return {}; } | ||||
|         logic_t operator>=(logic_t) const { return {}; } | ||||
|         logic_t operator==(logic_t) const { return {}; } | ||||
|         logic_t operator!=(logic_t) const { return {}; } | ||||
|         explicit operator bool() const { return true; } | ||||
|     }; | ||||
|  | ||||
|  | ||||
| // This is a minimal example for an issue we have found in 1.7.0 | ||||
|     struct foo { | ||||
|         int i; | ||||
| @@ -109,4 +122,16 @@ namespace { namespace CompilationTests { | ||||
|         REQUIRE(0 == y.v); | ||||
|     } | ||||
|  | ||||
|     // Comparison operators can return non-booleans. | ||||
|     // This is unusual, but should be supported. | ||||
|     TEST_CASE("#1147") { | ||||
|         logic_t t1, t2; | ||||
|         REQUIRE(t1 == t2); | ||||
|         REQUIRE(t1 != t2); | ||||
|         REQUIRE(t1 <  t2); | ||||
|         REQUIRE(t1 >  t2); | ||||
|         REQUIRE(t1 <= t2); | ||||
|         REQUIRE(t1 >= t2); | ||||
|     } | ||||
|  | ||||
| }} // namespace CompilationTests | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Martin Hořeňovský
					Martin Hořeňovský