Fixed an issue with round (#207)

* Fix the problem that the result has a decimal point when the round function, when the precision is 0.

* fix tests/test-functions.cpp:91 for round check
This commit is contained in:
逐雁南飛
2021-07-01 13:59:00 +08:00
committed by GitHub
parent c70fd585e5
commit 14f0d38cac
3 changed files with 11 additions and 3 deletions

View File

@@ -88,7 +88,7 @@ TEST_CASE("functions") {
}
SUBCASE("round") {
CHECK(env.render("{{ round(4, 0) }}", data) == "4.0");
CHECK(env.render("{{ round(4, 0) }}", data) == "4");
CHECK(env.render("{{ round(temperature, 2) }}", data) == "25.68");
// CHECK_THROWS_WITH( env.render("{{ round(name, 2) }}", data), "[inja.exception.json_error]
// [json.exception.type_error.302] type must be number, but is string" );