Skip to content

Commit

Permalink
Approx
Browse files Browse the repository at this point in the history
  • Loading branch information
bblanchon committed Sep 4, 2024
1 parent 98619dc commit 4a77a3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions extras/tests/JsonDeserializer/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ TEST_CASE("deserialize JSON array") {
}

SECTION("Float") {
DeserializationError err = deserializeJson(doc, "[4.3,1e2]");
DeserializationError err = deserializeJson(doc, "[4.2,1e2]");
JsonArray arr = doc.as<JsonArray>();

REQUIRE(err == DeserializationError::Ok);
REQUIRE(2 == arr.size());
REQUIRE(arr[0] == 4.3f);
REQUIRE(arr[0].as<float>() == Approx(4.2f));
REQUIRE(arr[1] == 1e2f);
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Expand All @@ -84,12 +84,12 @@ TEST_CASE("deserialize JSON array") {
}

SECTION("Double") {
DeserializationError err = deserializeJson(doc, "[12.33333333,-7E89]");
DeserializationError err = deserializeJson(doc, "[4.2123456,-7E89]");
JsonArray arr = doc.as<JsonArray>();

REQUIRE(err == DeserializationError::Ok);
REQUIRE(2 == arr.size());
REQUIRE(arr[0] == 12.33333333);
REQUIRE(arr[0].as<double>() == Approx(4.2123456));
REQUIRE(arr[1] == -7E89);
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()),
Expand Down
4 changes: 2 additions & 2 deletions extras/tests/JsonDeserializer/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ TEST_CASE("deserialize JSON object") {

SECTION("Double") {
DeserializationError err =
deserializeJson(doc, "{\"key1\":12.33333333,\"key2\":-7E89}");
deserializeJson(doc, "{\"key1\":12.3456789,\"key2\":-7E89}");
JsonObject obj = doc.as<JsonObject>();

REQUIRE(err == DeserializationError::Ok);
REQUIRE(doc.is<JsonObject>());
REQUIRE(obj.size() == 2);
REQUIRE(obj["key1"] == 12.33333333);
REQUIRE(obj["key1"].as<double>() == Approx(12.3456789));
REQUIRE(obj["key2"] == -7E89);
}

Expand Down

0 comments on commit 4a77a3f

Please sign in to comment.