diff --git a/CMakeLists.txt b/CMakeLists.txt index 841cdcc..761b68b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,17 @@ add_custom_command( -Dapostrophe.h -Sapostrophe.mustache -Sapostrophe.txt -Darray_of_strings.h -Sarray_of_strings.mustache -Sarray_of_strings.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 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test/data/) set_source_files_properties(${CMAKE_BINARY_DIR}/test_data.h PROPERTIES GENERATED TRUE) diff --git a/src/state/in_inverted_section.cpp b/src/state/in_inverted_section.cpp index 6d6ed8c..5796513 100644 --- a/src/state/in_inverted_section.cpp +++ b/src/state/in_inverted_section.cpp @@ -18,11 +18,8 @@ std::string state::in_inverted_section::render(render_context& context, const to case token_type::section_close: if(token.content() == section_name && skipped_openings == 0) { 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))) - out << "ÜRES: " + section_name + " " + section_text.str();//render_context(mstch::object{}, context).render(section_text.str()); - else - out << "NEMÜRES: " + section_name + " " + section_text.str(); + out << render_context(mstch::object{}, context).render(section_text.str()); context.set_state(); return out.str(); } else { diff --git a/test/data/bug_11_eating_whitespace.h b/test/data/bug_11_eating_whitespace.h index dcec017..ac9eb9b 100644 --- a/test/data/bug_11_eating_whitespace.h +++ b/test/data/bug_11_eating_whitespace.h @@ -1,3 +1,3 @@ -auto data = mstch::object{ +mstch::object{ {"tag", std::string{"yo"}} -}; +} diff --git a/test/data/bug_length_property.h b/test/data/bug_length_property.h index 224221c..f0f0b0c 100644 --- a/test/data/bug_length_property.h +++ b/test/data/bug_length_property.h @@ -1,3 +1,3 @@ -auto data = mstch::object{ +mstch::object{ {"length", std::string{"hello"}} -}; +} \ No newline at end of file diff --git a/test/data/context_lookup.h b/test/data/context_lookup.h index 9a52db0..445bb60 100644 --- a/test/data/context_lookup.h +++ b/test/data/context_lookup.h @@ -1,8 +1,8 @@ -auto data = mstch::object{ +mstch::object{ {"outer", mstch::object{ {"id", 1}, {"second", mstch::object{ {"nothing", 2} }} }} -}; +} \ No newline at end of file diff --git a/test/data/disappearing_whitespace.h b/test/data/disappearing_whitespace.h index 923c971..216b0bb 100644 --- a/test/data/disappearing_whitespace.h +++ b/test/data/disappearing_whitespace.h @@ -1,4 +1,4 @@ -auto data = mstch::object{ +mstch::object{ {"bedrooms", true}, {"total", 1} -}; +} \ No newline at end of file diff --git a/test/data/double_render.h b/test/data/double_render.h index 2b64ee6..a41f72f 100644 --- a/test/data/double_render.h +++ b/test/data/double_render.h @@ -1,5 +1,5 @@ -auto data = mstch::object{ +mstch::object{ {"foo", true}, {"bar", std::string{"{{win}}"}}, {"win", std::string{"FAIL"}} -}; +} \ No newline at end of file diff --git a/test/data/empty_list.h b/test/data/empty_list.h index a847639..66313a1 100644 --- a/test/data/empty_list.h +++ b/test/data/empty_list.h @@ -1,3 +1,3 @@ -auto data = mstch::object{ +mstch::object{ {"jobs", mstch::array{}} -}; +} \ No newline at end of file diff --git a/test/data/empty_sections.h b/test/data/empty_sections.h index f040324..2901e22 100644 --- a/test/data/empty_sections.h +++ b/test/data/empty_sections.h @@ -1 +1 @@ -auto data = mstch::object{}; +mstch::object{} \ No newline at end of file diff --git a/test/data/empty_string.h b/test/data/empty_string.h index e9e9d49..aebb474 100644 --- a/test/data/empty_string.h +++ b/test/data/empty_string.h @@ -1,6 +1,6 @@ -auto data = mstch::object{ +mstch::object{ {"description", std::string{"That is all!"}}, {"child", mstch::object{ {"description", std::string{""}} }} -}; +} \ No newline at end of file diff --git a/test/data/empty_template.h b/test/data/empty_template.h index f040324..2901e22 100644 --- a/test/data/empty_template.h +++ b/test/data/empty_template.h @@ -1 +1 @@ -auto data = mstch::object{}; +mstch::object{} \ No newline at end of file diff --git a/test/data/error_not_found.h b/test/data/error_not_found.h index f30ac4e..9694e93 100644 --- a/test/data/error_not_found.h +++ b/test/data/error_not_found.h @@ -1,3 +1,3 @@ -auto data = mstch::object{ +mstch::object{ {"bar", 2} -}; +} \ No newline at end of file diff --git a/test/data/falsy.h b/test/data/falsy.h index 163c58b..2db38c2 100644 --- a/test/data/falsy.h +++ b/test/data/falsy.h @@ -1,6 +1,6 @@ -auto data = mstch::object{ +mstch::object{ {"emptyString", std::string{""}}, {"emptyArray", mstch::array{}}, {"zero", 0}, {"null", mstch::node{}} -}; +} \ No newline at end of file diff --git a/test/filetoheader.cpp b/test/filetoheader.cpp index 9fc02f5..a7da079 100644 --- a/test/filetoheader.cpp +++ b/test/filetoheader.cpp @@ -22,8 +22,9 @@ void wrap_string(std::istream& input, std::ostream& output, const std::string& v while (std::getline(input, line)) { boost::replace_all(line, "\\", "\\\\"); boost::replace_all(line, "\"", "\\\""); - output << " \"" << line << "\\n\""; - if(!input.eof()) output << std::endl; + output << " \"" << line; + if(!input.eof()) output << "\\n"; + output << "\"" << std::endl; } output << "};" << std::endl; } diff --git a/test/main.cpp b/test/main.cpp index 60a3053..dd19b02 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -11,6 +11,17 @@ MSTCH_TEST("Ampersand escape", mstchtest::ampersand_escape) MSTCH_TEST("Apostrophe", mstchtest::apostrophe) MSTCH_TEST("Array of strings", mstchtest::array_of_strings) 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") { #include "data/ampersand_escape.h"