diff --git a/tests/test_parse_array.cpp b/tests/test_parse_array.cpp index 053d4c5..2d118c2 100644 --- a/tests/test_parse_array.cpp +++ b/tests/test_parse_array.cpp @@ -8,30 +8,30 @@ using namespace detail; BOOST_AUTO_TEST_CASE(test_oneline_array) { - TOML11_TEST_PARSE_EQUAL(parse_array, "[]", array()); + TOML11_TEST_PARSE_EQUAL_VAT(parse_array, "[]", array()); { array a(5); a[0] = toml::value(3); a[1] = toml::value(1); a[2] = toml::value(4); a[3] = toml::value(1); a[4] = toml::value(5); - TOML11_TEST_PARSE_EQUAL(parse_array, "[3,1,4,1,5]", a); + TOML11_TEST_PARSE_EQUAL_VAT(parse_array, "[3,1,4,1,5]", a); } { array a(3); a[0] = toml::value("foo"); a[1] = toml::value("bar"); a[2] = toml::value("baz"); - TOML11_TEST_PARSE_EQUAL(parse_array, "[\"foo\", \"bar\", \"baz\"]", a); + TOML11_TEST_PARSE_EQUAL_VAT(parse_array, "[\"foo\", \"bar\", \"baz\"]", a); } { array a(5); a[0] = toml::value(3); a[1] = toml::value(1); a[2] = toml::value(4); a[3] = toml::value(1); a[4] = toml::value(5); - TOML11_TEST_PARSE_EQUAL(parse_array, "[3,1,4,1,5,]", a); + TOML11_TEST_PARSE_EQUAL_VAT(parse_array, "[3,1,4,1,5,]", a); } { array a(3); a[0] = toml::value("foo"); a[1] = toml::value("bar"); a[2] = toml::value("baz"); - TOML11_TEST_PARSE_EQUAL(parse_array, "[\"foo\", \"bar\", \"baz\",]", a); + TOML11_TEST_PARSE_EQUAL_VAT(parse_array, "[\"foo\", \"bar\", \"baz\",]", a); } } @@ -66,8 +66,8 @@ BOOST_AUTO_TEST_CASE(test_oneline_array_value) BOOST_AUTO_TEST_CASE(test_multiline_array) { - TOML11_TEST_PARSE_EQUAL(parse_array>, "[\n#comment\n]", typename basic_value< discard_comments>::array_type()); - TOML11_TEST_PARSE_EQUAL(parse_array>, "[\n#comment\n]", typename basic_value::array_type()); + TOML11_TEST_PARSE_EQUAL_VAT(parse_array>, "[\n#comment\n]", typename basic_value< discard_comments>::array_type()); + TOML11_TEST_PARSE_EQUAL_VAT(parse_array>, "[\n#comment\n]", typename basic_value::array_type()); { typename basic_value::array_type a(5); @@ -76,7 +76,7 @@ BOOST_AUTO_TEST_CASE(test_multiline_array) a[2] = basic_value(4); a[3] = basic_value(1); a[4] = basic_value(5); - TOML11_TEST_PARSE_EQUAL(parse_array>, "[3,\n1,\n4,\n1,\n5]", a); + TOML11_TEST_PARSE_EQUAL_VAT(parse_array>, "[3,\n1,\n4,\n1,\n5]", a); } { typename basic_value::array_type a(5); @@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(test_multiline_array) a[2] = basic_value(4); a[3] = basic_value(1); a[4] = basic_value(5); - TOML11_TEST_PARSE_EQUAL(parse_array>, "[3,\n1,\n4,\n1,\n5]", a); + TOML11_TEST_PARSE_EQUAL_VAT(parse_array>, "[3,\n1,\n4,\n1,\n5]", a); } { @@ -95,7 +95,7 @@ BOOST_AUTO_TEST_CASE(test_multiline_array) a[2] = basic_value(4); a[3] = basic_value(1); a[4] = basic_value(5); - TOML11_TEST_PARSE_EQUAL(parse_array>, "[3,#comment\n1,#comment\n4,#comment\n1,#comment\n5 #comment\n]", a); + TOML11_TEST_PARSE_EQUAL_VAT(parse_array>, "[3,#comment\n1,#comment\n4,#comment\n1,#comment\n5 #comment\n]", a); } { typename basic_value::array_type a(5); @@ -104,7 +104,7 @@ BOOST_AUTO_TEST_CASE(test_multiline_array) a[2] = basic_value(4, {"comment"}); a[3] = basic_value(1, {"comment"}); a[4] = basic_value(5, {"comment"}); - TOML11_TEST_PARSE_EQUAL(parse_array>, "[3,#comment\n1,#comment\n4,#comment\n1,#comment\n5 #comment\n]", a); + TOML11_TEST_PARSE_EQUAL_VAT(parse_array>, "[3,#comment\n1,#comment\n4,#comment\n1,#comment\n5 #comment\n]", a); } @@ -113,14 +113,14 @@ BOOST_AUTO_TEST_CASE(test_multiline_array) a[0] = basic_value("foo"); a[1] = basic_value("bar"); a[2] = basic_value("baz"); - TOML11_TEST_PARSE_EQUAL(parse_array>, "[\"foo\",\n\"bar\",\n\"baz\"]", a); + TOML11_TEST_PARSE_EQUAL_VAT(parse_array>, "[\"foo\",\n\"bar\",\n\"baz\"]", a); } { typename basic_value::array_type a(3); a[0] = basic_value("foo"); a[1] = basic_value("bar"); a[2] = basic_value("baz"); - TOML11_TEST_PARSE_EQUAL(parse_array>, "[\"foo\",\n\"bar\",\n\"baz\"]", a); + TOML11_TEST_PARSE_EQUAL_VAT(parse_array>, "[\"foo\",\n\"bar\",\n\"baz\"]", a); } { @@ -128,14 +128,14 @@ BOOST_AUTO_TEST_CASE(test_multiline_array) a[0] = basic_value("foo"); a[1] = basic_value("b#r"); a[2] = basic_value("b#z"); - TOML11_TEST_PARSE_EQUAL(parse_array>, "[\"foo\",#comment\n\"b#r\",#comment\n\"b#z\"#comment\n]", a); + TOML11_TEST_PARSE_EQUAL_VAT(parse_array>, "[\"foo\",#comment\n\"b#r\",#comment\n\"b#z\"#comment\n]", a); } { typename basic_value::array_type a(3); a[0] = basic_value("foo", {"comment"}); a[1] = basic_value("b#r", {"comment"}); a[2] = basic_value("b#z", {"comment"}); - TOML11_TEST_PARSE_EQUAL(parse_array>, "[\"foo\",#comment\n\"b#r\",#comment\n\"b#z\"#comment\n]", a); + TOML11_TEST_PARSE_EQUAL_VAT(parse_array>, "[\"foo\",#comment\n\"b#r\",#comment\n\"b#z\"#comment\n]", a); } } diff --git a/tests/test_parse_aux.hpp b/tests/test_parse_aux.hpp index b9fd07c..331d4c8 100644 --- a/tests/test_parse_aux.hpp +++ b/tests/test_parse_aux.hpp @@ -20,11 +20,27 @@ do { \ } while(false); \ /**/ +#define TOML11_TEST_PARSE_EQUAL_VAT(psr, tkn, expct) \ +do { \ + const std::string token(tkn); \ + toml::detail::location loc("test", token); \ + const auto result = psr(loc, 0); \ + BOOST_TEST(result.is_ok()); \ + if(result.is_ok()){ \ + BOOST_TEST(result.unwrap().first == expct); \ + } else { \ + std::cerr << "parser " << #psr << " failed with input `"; \ + std::cerr << token << "`.\n"; \ + std::cerr << "reason: " << result.unwrap_err() << '\n'; \ + } \ +} while(false); \ +/**/ + #define TOML11_TEST_PARSE_EQUAL_VALUE(psr, tkn, expct) \ do { \ const std::string token(tkn); \ toml::detail::location loc("test", token); \ - const auto result = psr(loc); \ + const auto result = psr(loc, 0); \ BOOST_TEST(result.is_ok()); \ if(result.is_ok()){ \ BOOST_TEST(result.unwrap() == expct); \ @@ -35,3 +51,4 @@ do { \ } \ } while(false); \ /**/ + diff --git a/tests/test_parse_inline_table.cpp b/tests/test_parse_inline_table.cpp index 9217a23..a11767c 100644 --- a/tests/test_parse_inline_table.cpp +++ b/tests/test_parse_inline_table.cpp @@ -8,19 +8,19 @@ using namespace detail; BOOST_AUTO_TEST_CASE(test_inline_table) { - TOML11_TEST_PARSE_EQUAL(parse_inline_table, "{}", table()); + TOML11_TEST_PARSE_EQUAL_VAT(parse_inline_table, "{}", table()); { table t; t["foo"] = toml::value(42); t["bar"] = toml::value("baz"); - TOML11_TEST_PARSE_EQUAL(parse_inline_table, "{foo = 42, bar = \"baz\"}", t); + TOML11_TEST_PARSE_EQUAL_VAT(parse_inline_table, "{foo = 42, bar = \"baz\"}", t); } { table t; table t_sub; t_sub["name"] = toml::value("pug"); t["type"] = toml::value(t_sub); - TOML11_TEST_PARSE_EQUAL(parse_inline_table, "{type.name = \"pug\"}", t); + TOML11_TEST_PARSE_EQUAL_VAT(parse_inline_table, "{type.name = \"pug\"}", t); } }