diff --git a/test/test_main.cpp b/test/test_main.cpp index f1cb236..11f36ed 100644 --- a/test/test_main.cpp +++ b/test/test_main.cpp @@ -21,19 +21,21 @@ using namespace mstchtest; #define SPECS_TEST(x) TEST_CASE("specs_" #x) { \ using boost::get; \ auto data = json::parse(x ## _json); \ - for(auto& test_item: get(get(data)["tests"])) {\ + for (auto& test_item: get(get(data)["tests"])) {\ auto test = get(test_item); \ std::map partials; \ - if(test.count("partials")) \ - for(auto& partial_item: get(test["partials"])) \ + if (test.count("partials")) \ + for (auto& partial_item: get(test["partials"])) \ partials.insert(std::make_pair(partial_item.first, get(partial_item.second))); \ - for(std::pair& data_item: get(test["data"])) \ - if(data_item.first == "lambda") \ - data_item.second = specs_lambdas[get(test["name"])]; \ + mstch::map data; \ + for (auto& data_item: get(test["data"])) \ + if (data_item.first == "lambda") \ + data.insert(std::make_pair("lambda", specs_lambdas[get(test["name"])])); \ + else \ + data.insert(data_item); \ SECTION(get(test["name"])) \ - REQUIRE(mstch::render( \ - get(test["template"]), \ - test["data"], partials) == \ + REQUIRE( \ + mstch::render(get(test["template"]), data, partials) == \ get(test["expected"])); \ } \ }