mirror of
https://github.com/pantor/inja.git
synced 2026-02-17 09:03:58 +00:00
Initialize missing fields in Lexer constructor (#304)
* Initialize missing fields in Lexer constructor
- Add tok_start and pos initialization to Lexer constructor
- Fix clang-tidy uninitialized fields warning
Signed-off-by: Huang Rui <vowstar@gmail.com>
* Fix argument type mismatch for load_file and load_json methods
- Use .string() method for path objects in benchmark file loading
- Apply same path conversion in test cases for consistency
Signed-off-by: Huang Rui <vowstar@gmail.com>
* Fix and cleanup mismatch error in windows test case
- Use .string() method for path objects in benchmark file loading
- Fix test case failure introduced in 65aa8a669d
Signed-off-by: Huang Rui <vowstar@gmail.com>
---------
Signed-off-by: Huang Rui <vowstar@gmail.com>
This commit is contained in:
@@ -7,10 +7,10 @@ inja::Environment env;
|
||||
|
||||
const std::filesystem::path test_file_directory {"../test/data/benchmark/"};
|
||||
|
||||
const auto small_data = env.load_json(test_file_directory / "small_data.json");
|
||||
const auto large_data = env.load_json(test_file_directory / "large_data.json");
|
||||
const std::string medium_template = env.load_file(test_file_directory / "medium_template.txt");
|
||||
const std::string large_template = env.load_file(test_file_directory / "large_template.txt");
|
||||
const auto small_data = env.load_json((test_file_directory / "small_data.json").string());
|
||||
const auto large_data = env.load_json((test_file_directory / "large_data.json").string());
|
||||
const std::string medium_template = env.load_file((test_file_directory / "medium_template.txt").string());
|
||||
const std::string large_template = env.load_file((test_file_directory / "large_template.txt").string());
|
||||
|
||||
BENCHMARK(SmallDataMediumTemplate, render, 5, 30) {
|
||||
env.render(medium_template, small_data);
|
||||
|
||||
@@ -10,7 +10,7 @@ TEST_CASE("loading") {
|
||||
data["name"] = "Jeff";
|
||||
|
||||
SUBCASE("Files should be loaded") {
|
||||
CHECK(env.load_file(test_file_directory / "simple.txt") == "Hello {{ name }}.");
|
||||
CHECK(env.load_file((test_file_directory / "simple.txt").string()) == "Hello {{ name }}.");
|
||||
}
|
||||
|
||||
SUBCASE("Files should be rendered") {
|
||||
@@ -22,7 +22,7 @@ TEST_CASE("loading") {
|
||||
}
|
||||
|
||||
SUBCASE("File error should throw") {
|
||||
std::string path(test_file_directory / "does-not-exist");
|
||||
std::string path = (test_file_directory / "does-not-exist").string();
|
||||
|
||||
std::string file_error_message = "[inja.exception.file_error] failed accessing file at '" + path + "'";
|
||||
CHECK_THROWS_WITH(env.load_file(path), file_error_message.c_str());
|
||||
@@ -98,7 +98,7 @@ TEST_CASE("include-in-memory-and-file-template") {
|
||||
inja::json data;
|
||||
data["name"] = "Jeff";
|
||||
|
||||
std::string error_message = "[inja.exception.file_error] failed accessing file at '" + test_file_directory.string() + "/body'";
|
||||
std::string error_message = "[inja.exception.file_error] failed accessing file at '" + (test_file_directory / "body").string() + "'";
|
||||
CHECK_THROWS_WITH(env.render_file("include-both.txt", data), error_message.c_str());
|
||||
|
||||
const auto parsed_body_template = env.parse("Bye {{ name }}.");
|
||||
|
||||
Reference in New Issue
Block a user