From 31665994f4482be7bdb8bfb05bb5c6bcd7ec8d3b Mon Sep 17 00:00:00 2001 From: "Meredith L. Patterson" <mlp@thesmartpolitenerd.com> Date: Wed, 20 Feb 2013 22:03:52 -0500 Subject: [PATCH] h_attr_bool didn't have tests implemented. It does now. --- src/t_parser.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/t_parser.c b/src/t_parser.c index aa44234e..3654030f 100644 --- a/src/t_parser.c +++ b/src/t_parser.c @@ -347,8 +347,19 @@ static void test_epsilon_p(void) { g_check_parse_ok(epsilon_p_3, "a", 1, "(u0x61)"); } +bool validate_test_ab(HParseResult *p) { + if (TT_SEQUENCE != p->ast->token_type) + return false; + return (p->ast->seq->elements[0]->bytes.token == p->ast->seq->elements[1]->bytes.token); +} + static void test_attr_bool(void) { + const HParser *ab_ = h_attr_bool(h_many1(h_choice(h_ch('a'), h_ch('b'), NULL)), + validate_test_ab); + g_check_parse_ok(ab_, "aa", 2, "(u0x61 u0x61)"); + g_check_parse_ok(ab_, "bb", 2, "(u0x62 u0x62)"); + g_check_parse_failed(ab_, "ab", 2); } static void test_and(void) { -- GitLab