templates, split parser and renderer, c++ class parser

This commit is contained in:
pantor
2017-11-21 21:19:52 +01:00
parent 27140612b3
commit 2c96b3bdf5
7 changed files with 370 additions and 398 deletions

View File

@@ -4,11 +4,16 @@
TEST_CASE("Basic search in string") {
TEST_CASE("dot to pointer") {
CHECK( inja::dot_to_json_pointer_notation("person.names.surname") == "/person/names/surname" );
CHECK( inja::dot_to_json_pointer_notation("guests.2") == "/guests/2" );
}
TEST_CASE("basic-search") {
std::string input = "lorem ipsum dolor it";
inja::Regex regex("i(.*)m");
SECTION("Basic search from start") {
SECTION("from start") {
inja::Match match = inja::search(input, regex, 0);
CHECK( match.found() == true );
CHECK( match.position() == 6 );
@@ -18,17 +23,17 @@ TEST_CASE("Basic search in string") {
CHECK( match.str(1) == "psu" );
}
SECTION("Basic search from position") {
SECTION("from position") {
inja::Match match = inja::search(input, regex, 8);
CHECK( match.found() == false );
CHECK( match.length() == 0 );
}
}
TEST_CASE("Search in string with multiple possible regexes") {
TEST_CASE("search-with-multiple-possible-regexes") {
std::string input = "lorem ipsum dolor amit estas tronum.";
SECTION("Basic 1") {
SECTION("basic 1") {
std::vector<inja::Regex> regex_patterns = { inja::Regex("tras"), inja::Regex("do(\\w*)or"), inja::Regex("es(\\w*)as"), inja::Regex("ip(\\w*)um") };
inja::Match match = inja::search(input, regex_patterns, 0);
CHECK( match.regex_number() == 3 );
@@ -36,7 +41,7 @@ TEST_CASE("Search in string with multiple possible regexes") {
CHECK( match.str(1) == "s" );
}
SECTION("Basic 2") {
SECTION("basic 2") {
std::vector<inja::Regex> regex_patterns = { inja::Regex("tras"), inja::Regex("ip(\\w*)um"), inja::Regex("do(\\w*)or"), inja::Regex("es(\\w*)as") };
inja::Match match = inja::search(input, regex_patterns, 0);
CHECK( match.regex_number() == 1 );
@@ -45,7 +50,7 @@ TEST_CASE("Search in string with multiple possible regexes") {
}
}
TEST_CASE("Search on level") {
TEST_CASE("search-on-level") {
std::string input = "(% up %)(% up %)Test(% N1 %)(% down %)...(% up %)(% N2 %)(% up %)(% N3 %)(% down %)(% N4 %)(% down %)(% N5 %)(% down %)";
inja::Regex regex_statement("\\(\\% (.*?) \\%\\)");
@@ -53,7 +58,7 @@ TEST_CASE("Search on level") {
inja::Regex regex_level_down("down");
inja::Regex regex_search("N(\\d+)");
SECTION("First instance") {
SECTION("first instance") {
inja::Match open_match = inja::search(input, regex_statement, 0);
CHECK( open_match.position() == 0 );
CHECK( open_match.end_position() == 8 );
@@ -64,7 +69,7 @@ TEST_CASE("Search on level") {
CHECK( match.end_position() == 109 );
}
SECTION("Second instance") {
SECTION("second instance") {
inja::Match open_match = inja::search(input, regex_statement, 4);
CHECK( open_match.position() == 8 );