🐛 fix for #512
We totally forgot to implement the comparison operators other than == and != for scalar types. Consequently, comparing a JSON value with a scalar type led to compile errors.
This commit is contained in:
		
							parent
							
								
									4f6b63e492
								
							
						
					
					
						commit
						90273e930c
					
				
					 3 changed files with 211 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -973,4 +973,39 @@ TEST_CASE("regression tests")
 | 
			
		|||
        // check if serializations match
 | 
			
		||||
        CHECK(json::to_cbor(j2) == vec2);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    SECTION("issue #512 - use of overloaded operator '<=' is ambiguous")
 | 
			
		||||
    {
 | 
			
		||||
        json j;
 | 
			
		||||
        j["a"] = 5;
 | 
			
		||||
 | 
			
		||||
        // json op scalar
 | 
			
		||||
        CHECK(j["a"] == 5);
 | 
			
		||||
        CHECK(j["a"] != 4);
 | 
			
		||||
 | 
			
		||||
        CHECK(j["a"] <= 7);
 | 
			
		||||
        CHECK(j["a"] <  7);
 | 
			
		||||
        CHECK(j["a"] >= 3);
 | 
			
		||||
        CHECK(j["a"] >  3);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        CHECK(not(j["a"] <= 4));
 | 
			
		||||
        CHECK(not(j["a"] <  4));
 | 
			
		||||
        CHECK(not(j["a"] >= 6));
 | 
			
		||||
        CHECK(not(j["a"] >  6));
 | 
			
		||||
 | 
			
		||||
        // scalar op json
 | 
			
		||||
        CHECK(5 == j["a"]);
 | 
			
		||||
        CHECK(4 != j["a"]);
 | 
			
		||||
 | 
			
		||||
        CHECK(7 >= j["a"]);
 | 
			
		||||
        CHECK(7 >  j["a"]);
 | 
			
		||||
        CHECK(3 <= j["a"]);
 | 
			
		||||
        CHECK(3 <  j["a"]);
 | 
			
		||||
 | 
			
		||||
        CHECK(not(4 >= j["a"]));
 | 
			
		||||
        CHECK(not(4 >  j["a"]));
 | 
			
		||||
        CHECK(not(6 <= j["a"]));
 | 
			
		||||
        CHECK(not(6 <  j["a"]));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue