mirror of
https://github.com/pantor/inja.git
synced 2026-09-27 16:10:38 +00:00
add test and readme
This commit is contained in:
Executable
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"xarray": [0, 1],
|
||||
"yarray": [0, 1, 2]
|
||||
}
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
0-0
|
||||
0-1
|
||||
0-2
|
||||
1-0
|
||||
1-1
|
||||
1-2
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
{% for x in xarray %}{% for y in yarray %}
|
||||
{{x}}-{{y}}
|
||||
{% endfor %}{% endfor %}
|
||||
@@ -41,6 +41,18 @@ TEST_CASE("complete-files") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("complete-files-whitespace-control") {
|
||||
inja::Environment env {test_file_directory};
|
||||
env.set_trim_blocks(true);
|
||||
env.set_lstrip_blocks(true);
|
||||
|
||||
for (std::string test_name : {"nested-whitespace"}) {
|
||||
SECTION(test_name) {
|
||||
CHECK( env.render_file_with_json_file(test_name + "/template.txt", test_name + "/data.json") == env.load_file(test_name + "/result.txt") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("global-path") {
|
||||
inja::Environment env {test_file_directory, "./"};
|
||||
inja::Environment env_result {"./"};
|
||||
|
||||
@@ -7,8 +7,9 @@ using json = nlohmann::json;
|
||||
|
||||
TEST_CASE("dot-to-pointer") {
|
||||
std::string buffer;
|
||||
CHECK( inja::convert_dot_to_json_pointer("person.names.surname", buffer) == "/person/names/surname" );
|
||||
CHECK( inja::convert_dot_to_json_pointer("test", buffer) == "/test" );
|
||||
CHECK( inja::convert_dot_to_json_pointer("guests.2", buffer) == "/guests/2" );
|
||||
CHECK( inja::convert_dot_to_json_pointer("person.names.surname", buffer) == "/person/names/surname" );
|
||||
}
|
||||
|
||||
TEST_CASE("types") {
|
||||
@@ -172,7 +173,6 @@ TEST_CASE("functions") {
|
||||
SECTION("length") {
|
||||
CHECK( env.render("{{ length(names) }}", data) == "4" ); // Length of array
|
||||
CHECK( env.render("{{ length(name) }}", data) == "5" ); // Length of string
|
||||
|
||||
// CHECK_THROWS_WITH( env.render("{{ length(5) }}", data), "[inja.exception.json_error] [json.exception.type_error.302] type must be array, but is number" );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user