mirror of
https://github.com/pantor/inja.git
synced 2026-10-07 12:57:17 +00:00
add sort function
This commit is contained in:
1 parent
37d16d3c3a
commit
9f97c9add1
3 files changed
+25
-5
No files matched your search
@@ -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" );
|
||||
|
||||
Reference in new issue
Block a user