mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Remove DeserializationError == bool and DeserializationError != bool
				
					
				
			This commit is contained in:
		| @@ -10,6 +10,7 @@ HEAD | |||||||
| * Change the default of `ARDUINOJSON_USE_LONG_LONG` to `1` on 32-bit platforms | * Change the default of `ARDUINOJSON_USE_LONG_LONG` to `1` on 32-bit platforms | ||||||
| * Add `as<JsonString>()` and `is<JsonString>()` | * Add `as<JsonString>()` and `is<JsonString>()` | ||||||
| * Add safe bool idiom in `JsonString` | * Add safe bool idiom in `JsonString` | ||||||
|  | * Remove `DeserializationError == bool` and `DeserializationError != bool` | ||||||
|  |  | ||||||
| v6.18.5 (2021-09-28) | v6.18.5 (2021-09-28) | ||||||
| ------- | ------- | ||||||
|   | |||||||
| @@ -11,14 +11,14 @@ void testStringification(DeserializationError error, std::string expected) { | |||||||
|  |  | ||||||
| void testBoolification(DeserializationError error, bool expected) { | void testBoolification(DeserializationError error, bool expected) { | ||||||
|   // DeserializationError on left-hand side |   // DeserializationError on left-hand side | ||||||
|   CHECK(error == expected); |   CHECK(bool(error) == expected); | ||||||
|   CHECK(error != !expected); |   CHECK(bool(error) != !expected); | ||||||
|   CHECK(!error == !expected); |   CHECK(!bool(error) == !expected); | ||||||
|  |  | ||||||
|   // DeserializationError on right-hand side |   // DeserializationError on right-hand side | ||||||
|   CHECK(expected == error); |   CHECK(expected == bool(error)); | ||||||
|   CHECK(!expected != error); |   CHECK(!expected != bool(error)); | ||||||
|   CHECK(!expected == !error); |   CHECK(!expected == !bool(error)); | ||||||
| } | } | ||||||
|  |  | ||||||
| #define TEST_STRINGIFICATION(symbol) \ | #define TEST_STRINGIFICATION(symbol) \ | ||||||
| @@ -70,34 +70,24 @@ TEST_CASE("DeserializationError") { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   SECTION("Comparisons") { |   SECTION("Use in a condition") { | ||||||
|     DeserializationError invalidInput(DeserializationError::InvalidInput); |     DeserializationError invalidInput(DeserializationError::InvalidInput); | ||||||
|     DeserializationError ok(DeserializationError::Ok); |     DeserializationError ok(DeserializationError::Ok); | ||||||
|  |  | ||||||
|     SECTION("DeserializationError == bool") { |     SECTION("if (!err)") { | ||||||
|       REQUIRE(invalidInput == true); |       if (!invalidInput) | ||||||
|       REQUIRE(ok == false); |         FAIL(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     SECTION("bool == DeserializationError") { |     SECTION("if (err)") { | ||||||
|       REQUIRE(true == invalidInput); |       if (ok) | ||||||
|       REQUIRE(false == ok); |         FAIL(); | ||||||
|     } |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|     SECTION("DeserializationError != bool") { |   SECTION("Comparisons") { | ||||||
|       REQUIRE(invalidInput != false); |     DeserializationError invalidInput(DeserializationError::InvalidInput); | ||||||
|       REQUIRE(ok != true); |     DeserializationError ok(DeserializationError::Ok); | ||||||
|     } |  | ||||||
|  |  | ||||||
|     SECTION("bool != DeserializationError") { |  | ||||||
|       REQUIRE(false != invalidInput); |  | ||||||
|       REQUIRE(true != ok); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     SECTION("Negations") { |  | ||||||
|       REQUIRE(!invalidInput == false); |  | ||||||
|       REQUIRE(!ok == true); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     SECTION("DeserializationError == Code") { |     SECTION("DeserializationError == Code") { | ||||||
|       REQUIRE(invalidInput == DeserializationError::InvalidInput); |       REQUIRE(invalidInput == DeserializationError::InvalidInput); | ||||||
|   | |||||||
| @@ -57,18 +57,6 @@ class DeserializationError : public SafeBoolIdom<DeserializationError> { | |||||||
|   operator bool_type() const { |   operator bool_type() const { | ||||||
|     return _code != Ok ? safe_true() : safe_false(); |     return _code != Ok ? safe_true() : safe_false(); | ||||||
|   } |   } | ||||||
|   friend bool operator==(bool value, const DeserializationError& err) { |  | ||||||
|     return static_cast<bool>(err) == value; |  | ||||||
|   } |  | ||||||
|   friend bool operator==(const DeserializationError& err, bool value) { |  | ||||||
|     return static_cast<bool>(err) == value; |  | ||||||
|   } |  | ||||||
|   friend bool operator!=(bool value, const DeserializationError& err) { |  | ||||||
|     return static_cast<bool>(err) != value; |  | ||||||
|   } |  | ||||||
|   friend bool operator!=(const DeserializationError& err, bool value) { |  | ||||||
|     return static_cast<bool>(err) != value; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // Returns internal enum, useful for switch statement |   // Returns internal enum, useful for switch statement | ||||||
|   Code code() const { |   Code code() const { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user