From f6c90ccf61db2e1e42852749711169be5c8cf9e7 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 5 Jan 2024 00:44:43 +0000 Subject: [PATCH] tests: Make sure we can make a double from a string --- tests/tests_json.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/tests_json.cpp b/tests/tests_json.cpp index 4e20b90a0..8e55637a5 100644 --- a/tests/tests_json.cpp +++ b/tests/tests_json.cpp @@ -137,4 +137,14 @@ TEST_CASE("u_json") CHECK(json_node["alpha"][3].asObject()["gamma"].asInt() == 5); CHECK(json_node["iota"].hasKey("kappa")); } + + SECTION("Can make a double") + { + JSONNode stringToDouble("0.5"); + + constexpr float e = std::numeric_limits::epsilon(); + + CHECK(stringToDouble.isDouble()); + CHECK(stringToDouble.asDouble() == Approx(0.5).margin(e)); + } }