mirror of
https://github.com/pantor/inja.git
synced 2026-05-16 09:25:23 +00:00
little bit more code style
This commit is contained in:
+10
-8
@@ -1,3 +1,5 @@
|
||||
// Copyright (c) 2019 Pantor. All rights reserved.
|
||||
|
||||
#include "catch/catch.hpp"
|
||||
#include "inja/inja.hpp"
|
||||
|
||||
@@ -13,21 +15,21 @@ TEST_CASE("loading") {
|
||||
data["name"] = "Jeff";
|
||||
|
||||
SECTION("Files should be loaded") {
|
||||
CHECK( env.load_file(test_file_directory + "simple.txt") == "Hello {{ name }}." );
|
||||
CHECK(env.load_file(test_file_directory + "simple.txt") == "Hello {{ name }}.");
|
||||
}
|
||||
|
||||
SECTION("Files should be rendered") {
|
||||
CHECK( env.render_file(test_file_directory + "simple.txt", data) == "Hello Jeff." );
|
||||
CHECK(env.render_file(test_file_directory + "simple.txt", data) == "Hello Jeff.");
|
||||
}
|
||||
|
||||
SECTION("File includes should be rendered") {
|
||||
CHECK( env.render_file(test_file_directory + "include.txt", data) == "Answer: Hello Jeff." );
|
||||
CHECK(env.render_file(test_file_directory + "include.txt", data) == "Answer: Hello Jeff.");
|
||||
}
|
||||
|
||||
SECTION("File error should throw") {
|
||||
std::string path(test_file_directory + "does-not-exist");
|
||||
CHECK_THROWS_WITH( env.load_file(path), "[inja.exception.file_error] failed accessing file at '" + path + "'" );
|
||||
CHECK_THROWS_WITH( env.load_json(path), "[inja.exception.file_error] failed accessing file at '" + path + "'" );
|
||||
CHECK_THROWS_WITH(env.load_file(path), "[inja.exception.file_error] failed accessing file at '" + path + "'");
|
||||
CHECK_THROWS_WITH(env.load_json(path), "[inja.exception.file_error] failed accessing file at '" + path + "'");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +38,7 @@ TEST_CASE("complete-files") {
|
||||
|
||||
for (std::string test_name : {"simple-file", "nested", "nested-line", "html"}) {
|
||||
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") );
|
||||
CHECK(env.render_file_with_json_file(test_name + "/template.txt", test_name + "/data.json") == env.load_file(test_name + "/result.txt"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,7 +50,7 @@ TEST_CASE("complete-files-whitespace-control") {
|
||||
|
||||
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") );
|
||||
CHECK(env.render_file_with_json_file(test_name + "/template.txt", test_name + "/data.json") == env.load_file(test_name + "/result.txt"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,6 +63,6 @@ TEST_CASE("global-path") {
|
||||
|
||||
SECTION("Files should be written") {
|
||||
env.write("simple.txt", data, "global-path-result.txt");
|
||||
CHECK( env_result.load_file("global-path-result.txt") == "Hello Jeff." );
|
||||
CHECK(env_result.load_file("global-path-result.txt") == "Hello Jeff.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user