| 21 | |
| 22 | |
| 23 | int main() |
| 24 | { |
| 25 | |
| 26 | // if_ |
| 27 | { |
| 28 | { |
| 29 | std::string str = "a"; |
| 30 | auto result = parse(str, if_(true_)[char_]); |
| 31 | BOOST_TEST(result); |
| 32 | BOOST_TEST(*result == 'a'); |
| 33 | BOOST_TEST(!parse(str, if_(false_)[char_])); |
| 34 | } |
| 35 | { |
| 36 | std::string str = "a"; |
| 37 | auto result = parse(str, if_(true_)[char_]); |
| 38 | BOOST_TEST(result); |
| 39 | BOOST_TEST(*result == 'a'); |
| 40 | BOOST_TEST(!parse(str, if_(false_)[char_])); |
| 41 | BOOST_TEST(!parse(str, if_(true_)[char_('b')])); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | // switch_ |
| 46 | { |
| 47 | { |
| 48 | std::string str = "a"; |
| 49 | auto result = parse(str, switch_(true_)(true, char_)); |
| 50 | BOOST_TEST(result); |
| 51 | BOOST_TEST(*result == 'a'); |
| 52 | } |
| 53 | { |
| 54 | std::string str = "a"; |
| 55 | auto result = parse(str, switch_(true)(true_, char_)); |
| 56 | BOOST_TEST(result); |
| 57 | BOOST_TEST(*result == 'a'); |
| 58 | } |
| 59 | { |
| 60 | std::string str = "a"; |
| 61 | auto result = parse(str, switch_(true)(true, char_)); |
| 62 | BOOST_TEST(result); |
| 63 | BOOST_TEST(*result == 'a'); |
| 64 | } |
| 65 | { |
| 66 | std::string str = "a"; |
| 67 | auto result = parse(str, switch_(true_)(true_, char_)); |
| 68 | BOOST_TEST(result); |
| 69 | BOOST_TEST(*result == 'a'); |
| 70 | } |
| 71 | |
| 72 | { |
| 73 | std::string str = "a"; |
| 74 | auto result = parse(str, switch_(true_)(false, char_)); |
| 75 | BOOST_TEST(!result); |
| 76 | } |
| 77 | { |
| 78 | std::string str = "a"; |
| 79 | auto result = parse(str, switch_(true)(false_, char_)); |
| 80 | BOOST_TEST(!result); |