tests: Make sure we can make a double from a string

This commit is contained in:
Jakob Bornecrantz 2024-01-05 00:44:43 +00:00
parent 4e1a3e1afa
commit f6c90ccf61

View file

@ -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<float>::epsilon();
CHECK(stringToDouble.isDouble());
CHECK(stringToDouble.asDouble() == Approx(0.5).margin(e));
}
}