| 17 | BOOST_PARSER_DEFINE_RULES(symrule); |
| 18 | |
| 19 | int main() |
| 20 | { |
| 21 | // symbols_empty |
| 22 | { |
| 23 | symbols<int> roman_numerals; |
| 24 | symbols<std::string> named_strings; |
| 25 | |
| 26 | std::string const str = "I"; |
| 27 | BOOST_TEST(!parse(str, roman_numerals)); |
| 28 | BOOST_TEST(!parse(str, named_strings)); |
| 29 | } |
| 30 | |
| 31 | // symbols_simple |
| 32 | { |
| 33 | symbols<int> const roman_numerals = { |
| 34 | {"I", 1}, {"V", 5}, {"X", 10}, {"L", 50}, {"C", 100}}; |
| 35 | symbols<std::string> const named_strings = { |
| 36 | {"I", "1"}, {"V", "5"}, {"X", "10"}, {"L", "50"}, {"C", "100"}}; |
| 37 | |
| 38 | { |
| 39 | auto const result = parse("I", roman_numerals); |
| 40 | BOOST_TEST(result); |
| 41 | BOOST_TEST(*result == 1); |
| 42 | } |
| 43 | { |
| 44 | auto const result = parse("I", named_strings); |
| 45 | BOOST_TEST(result); |
| 46 | BOOST_TEST(*result == "1"); |
| 47 | } |
| 48 | |
| 49 | { |
| 50 | auto const result = parse("L", roman_numerals); |
| 51 | BOOST_TEST(result); |
| 52 | BOOST_TEST(*result == 50); |
| 53 | } |
| 54 | { |
| 55 | auto const result = parse("L", named_strings); |
| 56 | BOOST_TEST(result); |
| 57 | BOOST_TEST(*result == "50"); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | // symbols_max_munch |
| 62 | { |
| 63 | symbols<int> const roman_numerals = { |
| 64 | {"I", 1}, |
| 65 | {"II", 2}, |
| 66 | {"III", 3}, |
| 67 | {"IV", 4}, |
| 68 | {"V", 5}, |
| 69 | {"VI", 6}, |
| 70 | {"VII", 7}, |
| 71 | {"VIII", 8}, |
| 72 | {"IX", 9}, |
| 73 | |
| 74 | {"X", 10}, |
| 75 | {"XX", 20}, |
| 76 | {"XXX", 30}, |
nothing calls this directly
no test coverage detected