mirror of
https://github.com/pantor/inja.git
synced 2026-04-24 08:39:26 +00:00
add line statements, new tests, c++11 in cmake
This commit is contained in:
@@ -28,7 +28,7 @@ TEST_CASE("Files handling") {
|
||||
TEST_CASE("Complete files") {
|
||||
Environment env = Environment("../test/data/");
|
||||
|
||||
for (std::string test_name : {"simple-file", "nested"}) {
|
||||
for (std::string test_name : {"simple-file", "nested", "nested-line"}) {
|
||||
SECTION(test_name) {
|
||||
CHECK( env.render_template_with_json_file(test_name + "/template.txt", test_name + "/data.json") == env.load_file(test_name + "/result.txt") );
|
||||
}
|
||||
|
||||
@@ -114,6 +114,20 @@ TEST_CASE("Parse structure") {
|
||||
json result = {{{"type", Type::Comment}, {"text", "lorem ipsum"}}};
|
||||
CHECK( env.parse(test) == result );
|
||||
}
|
||||
|
||||
SECTION("Line Statements") {
|
||||
std::string test = R"(## if true
|
||||
lorem ipsum
|
||||
## endif)";
|
||||
json result = {
|
||||
{{"type", Type::Condition}, {"children", {
|
||||
{{"type", Type::ConditionBranch}, {"command", "if true"}, {"children", {
|
||||
{{"type", Type::String}, {"text", "lorem ipsum"}}
|
||||
}}}
|
||||
}}}
|
||||
};
|
||||
CHECK( env.parse(test) == result );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Parse json") {
|
||||
|
||||
@@ -49,6 +49,14 @@ TEST_CASE("Search in string with multiple possible regexes") {
|
||||
CHECK( match.outer == "ipsum" );
|
||||
CHECK( match.inner == "s" );
|
||||
}
|
||||
|
||||
SECTION("Basic 3") {
|
||||
std::vector<std::string> regex_patterns = { "asdf", "qwer", "ip(\\w*)um", "ip(\\w*)um", "es(\\w*)as" };
|
||||
inja::SearchMatchVector match = inja::search(input, regex_patterns, 0);
|
||||
CHECK( match.regex_number == 2 );
|
||||
CHECK( match.outer == "ipsum" );
|
||||
CHECK( match.inner == "s" );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Search on level") {
|
||||
|
||||
Reference in New Issue
Block a user