add sort function

This commit is contained in:
pantor
2018-02-18 19:41:56 +01:00
parent 37d16d3c3a
commit 9f97c9add1
3 changed files with 25 additions and 5 deletions

View File

@@ -107,6 +107,12 @@ TEST_CASE("functions") {
// CHECK_THROWS_WITH( env.render("{{ length(5) }}", data), "[json.exception.type_error.302] type must be array, but is number" );
}
SECTION("sort") {
CHECK( env.render("{{ sort([3, 2, 1]) }}", data) == "[1,2,3]" );
CHECK( env.render("{{ sort([\"bob\", \"charlie\", \"alice\"]) }}", data) == "[\"alice\",\"bob\",\"charlie\"]" );
// CHECK_THROWS_WITH( env.render("{{ sort(5) }}", data), "[json.exception.type_error.302] type must be array, but is number" );
}
SECTION("first") {
CHECK( env.render("{{ first(names) }}", data) == "Jeff" );
// CHECK_THROWS_WITH( env.render("{{ length(5) }}", data), "[json.exception.type_error.302] type must be array, but is number" );