unit testing refactor
This commit is contained in:
parent
5ba777782e
commit
3b4580186c
@ -30,21 +30,21 @@ target_link_libraries(filetoheader ${Boost_PROGRAM_OPTIONS_LIBRARY})
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_BINARY_DIR}/test_data.h
|
||||
COMMAND ${CMAKE_BINARY_DIR}/filetoheader --output ${CMAKE_BINARY_DIR}/test_data.h --namespace mstchtest
|
||||
-Dampersand_escape.h -Sampersand_escape.mustache -Sampersand_escape.txt
|
||||
-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
|
||||
-Dampersand_escape.data -Sampersand_escape.mustache -Sampersand_escape.txt
|
||||
-Dapostrophe.data -Sapostrophe.mustache -Sapostrophe.txt
|
||||
-Darray_of_strings.data -Sarray_of_strings.mustache -Sarray_of_strings.txt
|
||||
-Dbackslashes.data -Sbackslashes.mustache -Sbackslashes.txt
|
||||
-Dbug_11_eating_whitespace.data -Sbug_11_eating_whitespace.mustache -Sbug_11_eating_whitespace.txt
|
||||
-Dbug_length_property.data -Sbug_length_property.mustache -Sbug_length_property.txt
|
||||
-Dcontext_lookup.data -Scontext_lookup.mustache -Scontext_lookup.txt
|
||||
-Ddisappearing_whitespace.data -Sdisappearing_whitespace.mustache -Sdisappearing_whitespace.txt
|
||||
-Ddouble_render.data -Sdouble_render.mustache -Sdouble_render.txt
|
||||
-Dempty_list.data -Sempty_list.mustache -Sempty_list.txt
|
||||
-Dempty_sections.data -Sempty_sections.mustache -Sempty_sections.txt
|
||||
-Dempty_string.data -Sempty_string.mustache -Sempty_string.txt
|
||||
-Dempty_template.data -Sempty_template.mustache -Sempty_template.txt
|
||||
-Derror_not_found.data -Serror_not_found.mustache -Serror_not_found.txt
|
||||
-Dfalsy.data -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)
|
||||
|
112
test/main.cpp
112
test/main.cpp
@ -1,11 +1,10 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
|
||||
#include "catch.hpp"
|
||||
|
||||
#include <mstch.h>
|
||||
|
||||
#include "mstch.h"
|
||||
#include "test_data.h"
|
||||
|
||||
#define MSTCH_TEST(x,y) TEST_CASE(x) { REQUIRE(y ## _txt == mstch::render(y ## _mustache, y ## _h)); }
|
||||
#define MSTCH_TEST(x,y) TEST_CASE(x) { REQUIRE(y ## _txt == mstch::render(y ## _mustache, y ## _data)); }
|
||||
|
||||
MSTCH_TEST("Ampersand escape", mstchtest::ampersand_escape)
|
||||
MSTCH_TEST("Apostrophe", mstchtest::apostrophe)
|
||||
@ -23,111 +22,6 @@ 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"
|
||||
auto tpl = file_to_string("data/ampersand_escape.mustache");
|
||||
auto exp = file_to_string("data/ampersand_escape.txt");
|
||||
REQUIRE(exp == mstch::render(tpl, data));
|
||||
}
|
||||
|
||||
TEST_CASE("Apostrophe") {
|
||||
#include "data/apostrophe.h"
|
||||
auto tpl = file_to_string("data/apostrophe.mustache");
|
||||
auto exp = file_to_string("data/apostrophe.txt");
|
||||
REQUIRE(exp == mstch::render(tpl, data));
|
||||
}
|
||||
|
||||
TEST_CASE("Array of strings") {
|
||||
#include "data/array_of_strings.h"
|
||||
auto tpl = file_to_string("data/array_of_strings.mustache");
|
||||
auto exp = file_to_string("data/array_of_strings.txt");
|
||||
REQUIRE(exp == mstch::render(tpl, data));
|
||||
}
|
||||
|
||||
TEST_CASE("Backslashes") {
|
||||
#include "data/backslashes.h"
|
||||
auto tpl = file_to_string("data/backslashes.mustache");
|
||||
auto exp = file_to_string("data/backslashes.txt");
|
||||
REQUIRE(exp == mstch::render(tpl, data));
|
||||
}
|
||||
|
||||
TEST_CASE("Bug 11 eating whitespace") {
|
||||
#include "data/bug_11_eating_whitespace.h"
|
||||
auto tpl = file_to_string("data/bug_11_eating_whitespace.mustache");
|
||||
auto exp = file_to_string("data/bug_11_eating_whitespace.txt");
|
||||
REQUIRE(exp == mstch::render(tpl, data));
|
||||
}
|
||||
|
||||
TEST_CASE("Bug length property") {
|
||||
#include "data/bug_length_property.h"
|
||||
auto tpl = file_to_string("data/bug_length_property.mustache");
|
||||
auto exp = file_to_string("data/bug_length_property.txt");
|
||||
REQUIRE(exp == mstch::render(tpl, data));
|
||||
}
|
||||
|
||||
TEST_CASE("Context lookup") {
|
||||
#include "data/context_lookup.h"
|
||||
auto tpl = file_to_string("data/context_lookup.mustache");
|
||||
auto exp = file_to_string("data/context_lookup.txt");
|
||||
REQUIRE(exp == mstch::render(tpl, data));
|
||||
}
|
||||
|
||||
TEST_CASE("Disappearing whitespace") {
|
||||
#include "data/disappearing_whitespace.h"
|
||||
auto tpl = file_to_string("data/disappearing_whitespace.mustache");
|
||||
auto exp = file_to_string("data/disappearing_whitespace.txt");
|
||||
REQUIRE(exp == mstch::render(tpl, data));
|
||||
}
|
||||
|
||||
TEST_CASE("Double render") {
|
||||
#include "data/double_render.h"
|
||||
auto tpl = file_to_string("data/double_render.mustache");
|
||||
auto exp = file_to_string("data/double_render.txt");
|
||||
REQUIRE(exp == mstch::render(tpl, data));
|
||||
}
|
||||
|
||||
TEST_CASE("Empty list") {
|
||||
#include "data/empty_list.h"
|
||||
auto tpl = file_to_string("data/empty_list.mustache");
|
||||
auto exp = file_to_string("data/empty_list.txt");
|
||||
REQUIRE(exp == mstch::render(tpl, data));
|
||||
}
|
||||
|
||||
TEST_CASE("Empty sections") {
|
||||
#include "data/empty_sections.h"
|
||||
auto tpl = file_to_string("data/empty_sections.mustache");
|
||||
auto exp = file_to_string("data/empty_sections.txt");
|
||||
REQUIRE(exp == mstch::render(tpl, data));
|
||||
}
|
||||
|
||||
TEST_CASE("Empty string") {
|
||||
#include "data/empty_string.h"
|
||||
auto tpl = file_to_string("data/empty_string.mustache");
|
||||
auto exp = file_to_string("data/empty_string.txt");
|
||||
REQUIRE(exp == mstch::render(tpl, data));
|
||||
}
|
||||
|
||||
TEST_CASE("Empty template") {
|
||||
#include "data/empty_template.h"
|
||||
auto tpl = file_to_string("data/empty_template.mustache");
|
||||
auto exp = file_to_string("data/empty_template.txt");
|
||||
REQUIRE(exp == mstch::render(tpl, data));
|
||||
}
|
||||
|
||||
TEST_CASE("Error not found") {
|
||||
#include "data/error_not_found.h"
|
||||
auto tpl = file_to_string("data/error_not_found.mustache");
|
||||
auto exp = file_to_string("data/error_not_found.txt");
|
||||
REQUIRE(exp == mstch::render(tpl, data));
|
||||
}
|
||||
|
||||
TEST_CASE("Falsy") {
|
||||
#include "data/falsy.h"
|
||||
auto tpl = file_to_string("data/falsy.mustache");
|
||||
auto exp = file_to_string("data/falsy.txt");
|
||||
REQUIRE(exp == mstch::render(tpl, data));
|
||||
}*/
|
||||
|
||||
/*TEST_CASE("Falsy array") {
|
||||
#include "data/falsy_array.h"
|
||||
auto tpl = file_to_string("data/falsy_array.mustache");
|
||||
|
Loading…
Reference in New Issue
Block a user