more unit tests
This commit is contained in:
parent
bd4eb1349a
commit
5ba777782e
@ -34,6 +34,17 @@ add_custom_command(
|
|||||||
-Dapostrophe.h -Sapostrophe.mustache -Sapostrophe.txt
|
-Dapostrophe.h -Sapostrophe.mustache -Sapostrophe.txt
|
||||||
-Darray_of_strings.h -Sarray_of_strings.mustache -Sarray_of_strings.txt
|
-Darray_of_strings.h -Sarray_of_strings.mustache -Sarray_of_strings.txt
|
||||||
-Dbackslashes.h -Sbackslashes.mustache -Sbackslashes.txt
|
-Dbackslashes.h -Sbackslashes.mustache -Sbackslashes.txt
|
||||||
|
-Dbug_11_eating_whitespace.h -Sbug_11_eating_whitespace.mustache -Sbug_11_eating_whitespace.txt
|
||||||
|
-Dbug_length_property.h -Sbug_length_property.mustache -Sbug_length_property.txt
|
||||||
|
-Dcontext_lookup.h -Scontext_lookup.mustache -Scontext_lookup.txt
|
||||||
|
-Ddisappearing_whitespace.h -Sdisappearing_whitespace.mustache -Sdisappearing_whitespace.txt
|
||||||
|
-Ddouble_render.h -Sdouble_render.mustache -Sdouble_render.txt
|
||||||
|
-Dempty_list.h -Sempty_list.mustache -Sempty_list.txt
|
||||||
|
-Dempty_sections.h -Sempty_sections.mustache -Sempty_sections.txt
|
||||||
|
-Dempty_string.h -Sempty_string.mustache -Sempty_string.txt
|
||||||
|
-Dempty_template.h -Sempty_template.mustache -Sempty_template.txt
|
||||||
|
-Derror_not_found.h -Serror_not_found.mustache -Serror_not_found.txt
|
||||||
|
-Dfalsy.h -Sfalsy.mustache -Sfalsy.txt
|
||||||
DEPENDS ${CMAKE_BINARY_DIR}/filetoheader
|
DEPENDS ${CMAKE_BINARY_DIR}/filetoheader
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test/data/)
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test/data/)
|
||||||
set_source_files_properties(${CMAKE_BINARY_DIR}/test_data.h PROPERTIES GENERATED TRUE)
|
set_source_files_properties(${CMAKE_BINARY_DIR}/test_data.h PROPERTIES GENERATED TRUE)
|
||||||
|
@ -18,11 +18,8 @@ std::string state::in_inverted_section::render(render_context& context, const to
|
|||||||
case token_type::section_close:
|
case token_type::section_close:
|
||||||
if(token.content() == section_name && skipped_openings == 0) {
|
if(token.content() == section_name && skipped_openings == 0) {
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
out << boost::apply_visitor(visitor::to_json(), context.get_node(section_name));
|
|
||||||
if(boost::apply_visitor(visitor::is_node_empty(), context.get_node(section_name)))
|
if(boost::apply_visitor(visitor::is_node_empty(), context.get_node(section_name)))
|
||||||
out << "ÜRES: " + section_name + " " + section_text.str();//render_context(mstch::object{}, context).render(section_text.str());
|
out << render_context(mstch::object{}, context).render(section_text.str());
|
||||||
else
|
|
||||||
out << "NEMÜRES: " + section_name + " " + section_text.str();
|
|
||||||
context.set_state<outside_section>();
|
context.set_state<outside_section>();
|
||||||
return out.str();
|
return out.str();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
auto data = mstch::object{
|
mstch::object{
|
||||||
{"tag", std::string{"yo"}}
|
{"tag", std::string{"yo"}}
|
||||||
};
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
auto data = mstch::object{
|
mstch::object{
|
||||||
{"length", std::string{"hello"}}
|
{"length", std::string{"hello"}}
|
||||||
};
|
}
|
@ -1,8 +1,8 @@
|
|||||||
auto data = mstch::object{
|
mstch::object{
|
||||||
{"outer", mstch::object{
|
{"outer", mstch::object{
|
||||||
{"id", 1},
|
{"id", 1},
|
||||||
{"second", mstch::object{
|
{"second", mstch::object{
|
||||||
{"nothing", 2}
|
{"nothing", 2}
|
||||||
}}
|
}}
|
||||||
}}
|
}}
|
||||||
};
|
}
|
@ -1,4 +1,4 @@
|
|||||||
auto data = mstch::object{
|
mstch::object{
|
||||||
{"bedrooms", true},
|
{"bedrooms", true},
|
||||||
{"total", 1}
|
{"total", 1}
|
||||||
};
|
}
|
@ -1,5 +1,5 @@
|
|||||||
auto data = mstch::object{
|
mstch::object{
|
||||||
{"foo", true},
|
{"foo", true},
|
||||||
{"bar", std::string{"{{win}}"}},
|
{"bar", std::string{"{{win}}"}},
|
||||||
{"win", std::string{"FAIL"}}
|
{"win", std::string{"FAIL"}}
|
||||||
};
|
}
|
@ -1,3 +1,3 @@
|
|||||||
auto data = mstch::object{
|
mstch::object{
|
||||||
{"jobs", mstch::array{}}
|
{"jobs", mstch::array{}}
|
||||||
};
|
}
|
@ -1 +1 @@
|
|||||||
auto data = mstch::object{};
|
mstch::object{}
|
@ -1,6 +1,6 @@
|
|||||||
auto data = mstch::object{
|
mstch::object{
|
||||||
{"description", std::string{"That is all!"}},
|
{"description", std::string{"That is all!"}},
|
||||||
{"child", mstch::object{
|
{"child", mstch::object{
|
||||||
{"description", std::string{""}}
|
{"description", std::string{""}}
|
||||||
}}
|
}}
|
||||||
};
|
}
|
@ -1 +1 @@
|
|||||||
auto data = mstch::object{};
|
mstch::object{}
|
@ -1,3 +1,3 @@
|
|||||||
auto data = mstch::object{
|
mstch::object{
|
||||||
{"bar", 2}
|
{"bar", 2}
|
||||||
};
|
}
|
@ -1,6 +1,6 @@
|
|||||||
auto data = mstch::object{
|
mstch::object{
|
||||||
{"emptyString", std::string{""}},
|
{"emptyString", std::string{""}},
|
||||||
{"emptyArray", mstch::array{}},
|
{"emptyArray", mstch::array{}},
|
||||||
{"zero", 0},
|
{"zero", 0},
|
||||||
{"null", mstch::node{}}
|
{"null", mstch::node{}}
|
||||||
};
|
}
|
@ -22,8 +22,9 @@ void wrap_string(std::istream& input, std::ostream& output, const std::string& v
|
|||||||
while (std::getline(input, line)) {
|
while (std::getline(input, line)) {
|
||||||
boost::replace_all(line, "\\", "\\\\");
|
boost::replace_all(line, "\\", "\\\\");
|
||||||
boost::replace_all(line, "\"", "\\\"");
|
boost::replace_all(line, "\"", "\\\"");
|
||||||
output << " \"" << line << "\\n\"";
|
output << " \"" << line;
|
||||||
if(!input.eof()) output << std::endl;
|
if(!input.eof()) output << "\\n";
|
||||||
|
output << "\"" << std::endl;
|
||||||
}
|
}
|
||||||
output << "};" << std::endl;
|
output << "};" << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,17 @@ MSTCH_TEST("Ampersand escape", mstchtest::ampersand_escape)
|
|||||||
MSTCH_TEST("Apostrophe", mstchtest::apostrophe)
|
MSTCH_TEST("Apostrophe", mstchtest::apostrophe)
|
||||||
MSTCH_TEST("Array of strings", mstchtest::array_of_strings)
|
MSTCH_TEST("Array of strings", mstchtest::array_of_strings)
|
||||||
MSTCH_TEST("Backslashes", mstchtest::backslashes)
|
MSTCH_TEST("Backslashes", mstchtest::backslashes)
|
||||||
|
MSTCH_TEST("Eating whitespace", mstchtest::bug_11_eating_whitespace)
|
||||||
|
MSTCH_TEST("Length property", mstchtest::bug_length_property)
|
||||||
|
MSTCH_TEST("Context lookup", mstchtest::context_lookup)
|
||||||
|
MSTCH_TEST("Disappearing whitespace", mstchtest::disappearing_whitespace)
|
||||||
|
MSTCH_TEST("Double render", mstchtest::double_render)
|
||||||
|
MSTCH_TEST("Empty list", mstchtest::empty_list)
|
||||||
|
MSTCH_TEST("Empty sections", mstchtest::empty_sections)
|
||||||
|
MSTCH_TEST("Empty string", mstchtest::empty_string)
|
||||||
|
MSTCH_TEST("Empty template", mstchtest::empty_template)
|
||||||
|
MSTCH_TEST("Error not found", mstchtest::error_not_found)
|
||||||
|
MSTCH_TEST("Falsy", mstchtest::falsy)
|
||||||
|
|
||||||
/*TEST_CASE("Ampersand escape") {
|
/*TEST_CASE("Ampersand escape") {
|
||||||
#include "data/ampersand_escape.h"
|
#include "data/ampersand_escape.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user