mirror of
https://github.com/pantor/inja.git
synced 2026-05-19 02:35:23 +00:00
add meson build for testing
This commit is contained in:
+3
-1
@@ -1,7 +1,9 @@
|
||||
project('inja', 'cpp')
|
||||
project('inja', 'cpp', default_options : ['cpp_std=c++11'])
|
||||
|
||||
inja_inc = include_directories('src')
|
||||
|
||||
inja_dep = declare_dependency(
|
||||
include_directories : inja_inc
|
||||
)
|
||||
|
||||
subdir('test')
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ if(HUNTER_ENABLED) # Use Hunter to manage dependencies
|
||||
else() # Manage dependencies manually
|
||||
# Prepare "Catch" library for other executables
|
||||
add_library(Catch INTERFACE)
|
||||
target_include_directories(Catch INTERFACE "thirdparty/catch")
|
||||
target_include_directories(Catch INTERFACE "thirdparty")
|
||||
# Prepare "JSON" library for other executables
|
||||
add_library(JSON INTERFACE)
|
||||
target_include_directories(JSON INTERFACE "thirdparty")
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
unit_test = executable(
|
||||
'inja-test',
|
||||
'src/unit.cpp',
|
||||
'src/unit-files.cpp',
|
||||
'src/unit-renderer.cpp',
|
||||
'src/unit-string-helper.cpp',
|
||||
dependencies: inja_dep,
|
||||
include_directories: include_directories('thirdparty')
|
||||
)
|
||||
|
||||
test('Inja unit test', unit_test)
|
||||
+9
-19
@@ -1,4 +1,4 @@
|
||||
#include "catch.hpp"
|
||||
#include "catch/catch.hpp"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "inja.hpp"
|
||||
|
||||
@@ -12,20 +12,20 @@ TEST_CASE("loading") {
|
||||
data["name"] = "Jeff";
|
||||
|
||||
SECTION("Files should be loaded") {
|
||||
CHECK( env.load_global_file("data/simple.txt") == "Hello {{ name }}." );
|
||||
CHECK( env.load_global_file("../test/data/simple.txt") == "Hello {{ name }}." );
|
||||
}
|
||||
|
||||
SECTION("Files should be rendered") {
|
||||
CHECK( env.render_file("data/simple.txt", data) == "Hello Jeff." );
|
||||
CHECK( env.render_file("../test/data/simple.txt", data) == "Hello Jeff." );
|
||||
}
|
||||
|
||||
SECTION("File includes should be rendered") {
|
||||
CHECK( env.render_file("data/include.txt", data) == "Answer: Hello Jeff." );
|
||||
CHECK( env.render_file("../test/data/include.txt", data) == "Answer: Hello Jeff." );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("complete-files") {
|
||||
inja::Environment env = inja::Environment("data/");
|
||||
inja::Environment env = inja::Environment("../test/data/");
|
||||
|
||||
for (std::string test_name : {"simple-file", "nested", "nested-line"}) {
|
||||
SECTION(test_name) {
|
||||
@@ -35,23 +35,13 @@ TEST_CASE("complete-files") {
|
||||
}
|
||||
|
||||
TEST_CASE("global-path") {
|
||||
inja::Environment env = inja::Environment("data/");
|
||||
inja::Environment env = inja::Environment("../test/data/", "test/");
|
||||
inja::Environment env_result = inja::Environment("test/");
|
||||
json data;
|
||||
data["name"] = "Jeff";
|
||||
|
||||
SECTION("Files should be written") {
|
||||
env.write("simple.txt", data, "result.txt");
|
||||
CHECK( env.load_global_file("result.txt") == "Hello Jeff." );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("input-output-path") {
|
||||
inja::Environment env = inja::Environment("data/", "data/");
|
||||
json data;
|
||||
data["name"] = "Jeff";
|
||||
|
||||
SECTION("Files should be written") {
|
||||
env.write("simple.txt", data, "simple-result.txt");
|
||||
CHECK( env.load_global_file("simple-result.txt") == "Hello Jeff." );
|
||||
env.write("simple.txt", data, "global-path-result.txt");
|
||||
CHECK( env_result.load_global_file("global-path-result.txt") == "Hello Jeff." );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "catch.hpp"
|
||||
#include "catch/catch.hpp"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "inja.hpp"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "catch.hpp"
|
||||
#include "catch/catch.hpp"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "inja.hpp"
|
||||
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "catch.hpp"
|
||||
#include "catch/catch.hpp"
|
||||
|
||||
Reference in New Issue
Block a user