Rename some things in parse tree data structures

This commit is contained in:
2024-10-26 15:52:58 +01:00
parent fd9fd7ce7f
commit 295b68efa2
4 changed files with 149 additions and 175 deletions

View File

@@ -15,20 +15,18 @@ static void a_is_unchanged(void)
terms[0].type = PARSE_TERM_LITERAL;
terms[0].literal = 'a';
parse_sequence_t *alternatives = malloc(1 * sizeof(parse_sequence_t));
alternatives[0].len = alternatives[0].capacity = 1;
alternatives[0].count = alternatives[0].capacity = 1;
alternatives[0].contents = terms;
parse_tree_t t
= { .count = 1, .capacity = 1, .alternatives = alternatives };
parse_tree_t t = { .count = 1, .capacity = 1, .contents = alternatives };
desugar_regex(&t);
ASSERT_EQ(1, t.count);
ASSERT_NOT_NULL(t.alternatives);
ASSERT_EQ(1, t.alternatives[0].len);
ASSERT_NOT_NULL(t.alternatives[0].contents);
ASSERT_EQ(
PARSE_QUANTIFIER_NONE, t.alternatives[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.alternatives[0].contents[0].type);
ASSERT_EQ('a', t.alternatives[0].contents[0].literal);
ASSERT_NOT_NULL(t.contents);
ASSERT_EQ(1, t.contents[0].count);
ASSERT_NOT_NULL(t.contents[0].contents);
ASSERT_EQ(PARSE_QUANTIFIER_NONE, t.contents[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.contents[0].contents[0].type);
ASSERT_EQ('a', t.contents[0].contents[0].literal);
parse_free_tree_children(&t);
}
@@ -43,24 +41,23 @@ static void abc_is_unchanged(void)
terms[2].type = PARSE_TERM_LITERAL;
terms[2].literal = 'c';
parse_sequence_t *alternatives = malloc(1 * sizeof(parse_sequence_t));
alternatives[0].len = alternatives[0].capacity = 3;
alternatives[0].count = alternatives[0].capacity = 3;
alternatives[0].contents = terms;
parse_tree_t t
= { .count = 1, .capacity = 1, .alternatives = alternatives };
parse_tree_t t = { .count = 1, .capacity = 1, .contents = alternatives };
desugar_regex(&t);
ASSERT_EQ(1, t.count);
ASSERT_NOT_NULL(t.alternatives);
ASSERT_EQ(3, t.alternatives[0].len);
ASSERT_NOT_NULL(t.alternatives[0].contents);
ASSERT_EQ(PARSE_TERM_LITERAL, t.alternatives[0].contents[0].type);
ASSERT_EQ('a', t.alternatives[0].contents[0].literal);
ASSERT_NOT_NULL(t.alternatives[0].contents);
ASSERT_EQ(PARSE_TERM_LITERAL, t.alternatives[0].contents[1].type);
ASSERT_EQ('b', t.alternatives[0].contents[1].literal);
ASSERT_NOT_NULL(t.alternatives[0].contents);
ASSERT_EQ(PARSE_TERM_LITERAL, t.alternatives[0].contents[2].type);
ASSERT_EQ('c', t.alternatives[0].contents[2].literal);
ASSERT_NOT_NULL(t.contents);
ASSERT_EQ(3, t.contents[0].count);
ASSERT_NOT_NULL(t.contents[0].contents);
ASSERT_EQ(PARSE_TERM_LITERAL, t.contents[0].contents[0].type);
ASSERT_EQ('a', t.contents[0].contents[0].literal);
ASSERT_NOT_NULL(t.contents[0].contents);
ASSERT_EQ(PARSE_TERM_LITERAL, t.contents[0].contents[1].type);
ASSERT_EQ('b', t.contents[0].contents[1].literal);
ASSERT_NOT_NULL(t.contents[0].contents);
ASSERT_EQ(PARSE_TERM_LITERAL, t.contents[0].contents[2].type);
ASSERT_EQ('c', t.contents[0].contents[2].literal);
parse_free_tree_children(&t);
}
@@ -72,20 +69,18 @@ static void a_star_is_unchanged(void)
terms[0].type = PARSE_TERM_LITERAL;
terms[0].literal = 'a';
parse_sequence_t *alternatives = malloc(1 * sizeof(parse_sequence_t));
alternatives[0].len = alternatives[0].capacity = 1;
alternatives[0].count = alternatives[0].capacity = 1;
alternatives[0].contents = terms;
parse_tree_t t
= { .count = 1, .capacity = 1, .alternatives = alternatives };
parse_tree_t t = { .count = 1, .capacity = 1, .contents = alternatives };
desugar_regex(&t);
ASSERT_EQ(1, t.count);
ASSERT_NOT_NULL(t.alternatives);
ASSERT_EQ(1, t.alternatives[0].len);
ASSERT_NOT_NULL(t.alternatives[0].contents);
ASSERT_EQ(
PARSE_QUANTIFIER_STAR, t.alternatives[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.alternatives[0].contents[0].type);
ASSERT_EQ('a', t.alternatives[0].contents[0].literal);
ASSERT_NOT_NULL(t.contents);
ASSERT_EQ(1, t.contents[0].count);
ASSERT_NOT_NULL(t.contents[0].contents);
ASSERT_EQ(PARSE_QUANTIFIER_STAR, t.contents[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.contents[0].contents[0].type);
ASSERT_EQ('a', t.contents[0].contents[0].literal);
parse_free_tree_children(&t);
}
@@ -100,22 +95,21 @@ static void a_or_b_or_c_is_unchanged(void)
terms[0].type = PARSE_TERM_LITERAL;
terms[0].literal = literals[i];
alternatives[i].len = alternatives[i].capacity = 1;
alternatives[i].count = alternatives[i].capacity = 1;
alternatives[i].contents = terms;
}
parse_tree_t t
= { .count = 3, .capacity = 3, .alternatives = alternatives };
parse_tree_t t = { .count = 3, .capacity = 3, .contents = alternatives };
desugar_regex(&t);
ASSERT_EQ(3, t.count);
ASSERT_NOT_NULL(t.alternatives);
ASSERT_NOT_NULL(t.contents);
for (int i = 0; i < 3; ++i) {
ASSERT_EQ(1, t.alternatives[i].len);
ASSERT_NOT_NULL(t.alternatives[i].contents);
ASSERT_EQ(1, t.contents[i].count);
ASSERT_NOT_NULL(t.contents[i].contents);
ASSERT_EQ(
PARSE_QUANTIFIER_NONE, t.alternatives[i].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.alternatives[i].contents[0].type);
ASSERT_EQ(literals[i], t.alternatives[i].contents[0].literal);
PARSE_QUANTIFIER_NONE, t.contents[i].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.contents[i].contents[0].type);
ASSERT_EQ(literals[i], t.contents[i].contents[0].literal);
}
parse_free_tree_children(&t);
@@ -129,18 +123,17 @@ static void subexpr_a_is_unchanged(void)
inner_terms[0].literal = 'a';
parse_sequence_t *inner_alternatives
= malloc(1 * sizeof(parse_sequence_t));
inner_alternatives[0].len = inner_alternatives[0].capacity = 1;
inner_alternatives[0].count = inner_alternatives[0].capacity = 1;
inner_alternatives[0].contents = inner_terms;
parse_term_t *terms = malloc(1 * sizeof(parse_term_t));
terms[0].quantifier = PARSE_QUANTIFIER_NONE;
terms[0].type = PARSE_TERM_SUBEXPR;
terms[0].subexpr.count = terms[0].subexpr.capacity = 1;
terms[0].subexpr.alternatives = inner_alternatives;
terms[0].subexpr.contents = inner_alternatives;
parse_sequence_t *alternatives = malloc(1 * sizeof(parse_sequence_t));
alternatives[0].len = alternatives[0].capacity = 1;
alternatives[0].count = alternatives[0].capacity = 1;
alternatives[0].contents = terms;
parse_tree_t t
= { .count = 1, .capacity = 1, .alternatives = alternatives };
parse_tree_t t = { .count = 1, .capacity = 1, .contents = alternatives };
desugar_regex(&t);

View File

@@ -41,13 +41,12 @@ static void a_is_parsed_as_unquantified_literal(void)
const int result = PARSE_EXPR_STRING("a", &t);
ASSERT_NE(-1, result);
ASSERT_EQ(1, t.count);
ASSERT_NOT_NULL(t.alternatives);
ASSERT_NOT_NULL(t.contents);
ASSERT_EQ(1, t.alternatives[0].len);
ASSERT_EQ(
PARSE_QUANTIFIER_NONE, t.alternatives[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.alternatives[0].contents[0].type);
ASSERT_EQ('a', t.alternatives[0].contents[0].literal);
ASSERT_EQ(1, t.contents[0].count);
ASSERT_EQ(PARSE_QUANTIFIER_NONE, t.contents[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.contents[0].contents[0].type);
ASSERT_EQ('a', t.contents[0].contents[0].literal);
parse_free_tree_children(&t);
}
@@ -58,13 +57,12 @@ static void b_is_parsed_as_unquantified_literal(void)
const int result = PARSE_EXPR_STRING("b", &t);
ASSERT_NE(-1, result);
ASSERT_EQ(1, t.count);
ASSERT_NOT_NULL(t.alternatives);
ASSERT_NOT_NULL(t.contents);
ASSERT_EQ(1, t.alternatives[0].len);
ASSERT_EQ(
PARSE_QUANTIFIER_NONE, t.alternatives[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.alternatives[0].contents[0].type);
ASSERT_EQ('b', t.alternatives[0].contents[0].literal);
ASSERT_EQ(1, t.contents[0].count);
ASSERT_EQ(PARSE_QUANTIFIER_NONE, t.contents[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.contents[0].contents[0].type);
ASSERT_EQ('b', t.contents[0].contents[0].literal);
parse_free_tree_children(&t);
}
@@ -75,21 +73,18 @@ static void abc_is_parsed_as_sequence_of_unquantified_literals(void)
const int result = PARSE_EXPR_STRING("abc", &t);
ASSERT_NE(-1, result);
ASSERT_EQ(1, t.count);
ASSERT_NOT_NULL(t.alternatives);
ASSERT_NOT_NULL(t.contents);
ASSERT_EQ(3, t.alternatives[0].len);
ASSERT_EQ(
PARSE_QUANTIFIER_NONE, t.alternatives[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.alternatives[0].contents[0].type);
ASSERT_EQ('a', t.alternatives[0].contents[0].literal);
ASSERT_EQ(
PARSE_QUANTIFIER_NONE, t.alternatives[0].contents[1].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.alternatives[0].contents[1].type);
ASSERT_EQ('b', t.alternatives[0].contents[1].literal);
ASSERT_EQ(
PARSE_QUANTIFIER_NONE, t.alternatives[0].contents[2].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.alternatives[0].contents[2].type);
ASSERT_EQ('c', t.alternatives[0].contents[2].literal);
ASSERT_EQ(3, t.contents[0].count);
ASSERT_EQ(PARSE_QUANTIFIER_NONE, t.contents[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.contents[0].contents[0].type);
ASSERT_EQ('a', t.contents[0].contents[0].literal);
ASSERT_EQ(PARSE_QUANTIFIER_NONE, t.contents[0].contents[1].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.contents[0].contents[1].type);
ASSERT_EQ('b', t.contents[0].contents[1].literal);
ASSERT_EQ(PARSE_QUANTIFIER_NONE, t.contents[0].contents[2].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.contents[0].contents[2].type);
ASSERT_EQ('c', t.contents[0].contents[2].literal);
parse_free_tree_children(&t);
}
@@ -100,12 +95,11 @@ static void dot_is_parsed_as_unquantified_wildcard_term(void)
const int result = PARSE_EXPR_STRING(".", &t);
ASSERT_NE(-1, result);
ASSERT_EQ(1, t.count);
ASSERT_NOT_NULL(t.alternatives);
ASSERT_NOT_NULL(t.contents);
ASSERT_EQ(1, t.alternatives[0].len);
ASSERT_EQ(
PARSE_QUANTIFIER_NONE, t.alternatives[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_WILDCARD, t.alternatives[0].contents[0].type);
ASSERT_EQ(1, t.contents[0].count);
ASSERT_EQ(PARSE_QUANTIFIER_NONE, t.contents[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_WILDCARD, t.contents[0].contents[0].type);
parse_free_tree_children(&t);
}
@@ -116,13 +110,12 @@ static void backslash_dot_is_parsed_as_unquantified_literal(void)
const int result = PARSE_EXPR_STRING("\\.", &t);
ASSERT_NE(-1, result);
ASSERT_EQ(1, t.count);
ASSERT_NOT_NULL(t.alternatives);
ASSERT_NOT_NULL(t.contents);
ASSERT_EQ(1, t.alternatives[0].len);
ASSERT_EQ(
PARSE_QUANTIFIER_NONE, t.alternatives[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.alternatives[0].contents[0].type);
ASSERT_EQ('.', t.alternatives[0].contents[0].literal);
ASSERT_EQ(1, t.contents[0].count);
ASSERT_EQ(PARSE_QUANTIFIER_NONE, t.contents[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.contents[0].contents[0].type);
ASSERT_EQ('.', t.contents[0].contents[0].literal);
parse_free_tree_children(&t);
}
@@ -133,13 +126,12 @@ static void backslash_backslash_is_parsed_as_unquantified_literal(void)
const int result = PARSE_EXPR_STRING("\\\\", &t);
ASSERT_NE(-1, result);
ASSERT_EQ(1, t.count);
ASSERT_NOT_NULL(t.alternatives);
ASSERT_NOT_NULL(t.contents);
ASSERT_EQ(1, t.alternatives[0].len);
ASSERT_EQ(
PARSE_QUANTIFIER_NONE, t.alternatives[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.alternatives[0].contents[0].type);
ASSERT_EQ('\\', t.alternatives[0].contents[0].literal);
ASSERT_EQ(1, t.contents[0].count);
ASSERT_EQ(PARSE_QUANTIFIER_NONE, t.contents[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.contents[0].contents[0].type);
ASSERT_EQ('\\', t.contents[0].contents[0].literal);
parse_free_tree_children(&t);
}
@@ -150,29 +142,26 @@ static void a_pipe_b_in_parens_is_parsed_as_subexpr_term(void)
const int result = PARSE_EXPR_STRING("(a|b)", &t);
ASSERT_NE(-1, result);
ASSERT_EQ(1, t.count);
ASSERT_NOT_NULL(t.alternatives);
ASSERT_NOT_NULL(t.contents);
ASSERT_EQ(1, t.alternatives[0].len);
ASSERT_EQ(
PARSE_QUANTIFIER_NONE, t.alternatives[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_SUBEXPR, t.alternatives[0].contents[0].type);
ASSERT_EQ(1, t.contents[0].count);
ASSERT_EQ(PARSE_QUANTIFIER_NONE, t.contents[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_SUBEXPR, t.contents[0].contents[0].type);
const parse_tree_t *inner = &t.alternatives[0].contents[0].subexpr;
const parse_tree_t *inner = &t.contents[0].contents[0].subexpr;
ASSERT_EQ(2, inner->count);
ASSERT_EQ(1, inner->alternatives[0].len);
ASSERT_EQ(1, inner->contents[0].count);
ASSERT_EQ(
PARSE_QUANTIFIER_NONE,
inner->alternatives[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, inner->alternatives[0].contents[0].type);
ASSERT_EQ('a', inner->alternatives[0].contents[0].literal);
PARSE_QUANTIFIER_NONE, inner->contents[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, inner->contents[0].contents[0].type);
ASSERT_EQ('a', inner->contents[0].contents[0].literal);
ASSERT_EQ(1, inner->alternatives[1].len);
ASSERT_EQ(1, inner->contents[1].count);
ASSERT_EQ(
PARSE_QUANTIFIER_NONE,
inner->alternatives[1].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, inner->alternatives[1].contents[0].type);
ASSERT_EQ('b', inner->alternatives[1].contents[0].literal);
PARSE_QUANTIFIER_NONE, inner->contents[1].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, inner->contents[1].contents[0].type);
ASSERT_EQ('b', inner->contents[1].contents[0].literal);
parse_free_tree_children(&t);
}
@@ -183,24 +172,21 @@ static void a_in_parens_b_is_parsed_as_sequence_with_subexpr_term(void)
const int result = PARSE_EXPR_STRING("(a)b", &t);
ASSERT_NE(-1, result);
ASSERT_EQ(1, t.count);
ASSERT_NOT_NULL(t.alternatives);
ASSERT_NOT_NULL(t.contents);
ASSERT_EQ(2, t.alternatives[0].len);
ASSERT_EQ(
PARSE_QUANTIFIER_NONE, t.alternatives[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_SUBEXPR, t.alternatives[0].contents[0].type);
ASSERT_EQ(
PARSE_QUANTIFIER_NONE, t.alternatives[0].contents[1].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.alternatives[0].contents[1].type);
ASSERT_EQ('b', t.alternatives[0].contents[1].literal);
ASSERT_EQ(2, t.contents[0].count);
ASSERT_EQ(PARSE_QUANTIFIER_NONE, t.contents[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_SUBEXPR, t.contents[0].contents[0].type);
ASSERT_EQ(PARSE_QUANTIFIER_NONE, t.contents[0].contents[1].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, t.contents[0].contents[1].type);
ASSERT_EQ('b', t.contents[0].contents[1].literal);
const parse_tree_t *inner = &t.alternatives[0].contents[0].subexpr;
ASSERT_EQ(1, inner->alternatives[0].len);
const parse_tree_t *inner = &t.contents[0].contents[0].subexpr;
ASSERT_EQ(1, inner->contents[0].count);
ASSERT_EQ(
PARSE_QUANTIFIER_NONE,
inner->alternatives[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, inner->alternatives[0].contents[0].type);
ASSERT_EQ('a', inner->alternatives[0].contents[0].literal);
PARSE_QUANTIFIER_NONE, inner->contents[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_LITERAL, inner->contents[0].contents[0].type);
ASSERT_EQ('a', inner->contents[0].contents[0].literal);
parse_free_tree_children(&t);
}
@@ -211,12 +197,11 @@ static void dot_star_is_parsed_as_star_quantified_wildcard(void)
const int result = PARSE_EXPR_STRING(".*", &t);
ASSERT_NE(-1, result);
ASSERT_EQ(1, t.count);
ASSERT_NOT_NULL(t.alternatives);
ASSERT_NOT_NULL(t.contents);
ASSERT_EQ(1, t.alternatives[0].len);
ASSERT_EQ(
PARSE_QUANTIFIER_STAR, t.alternatives[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_WILDCARD, t.alternatives[0].contents[0].type);
ASSERT_EQ(1, t.contents[0].count);
ASSERT_EQ(PARSE_QUANTIFIER_STAR, t.contents[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_WILDCARD, t.contents[0].contents[0].type);
parse_free_tree_children(&t);
}
@@ -227,12 +212,11 @@ static void dot_plus_is_parsed_as_plus_quantified_wildcard(void)
const int result = PARSE_EXPR_STRING(".+", &t);
ASSERT_NE(-1, result);
ASSERT_EQ(1, t.count);
ASSERT_NOT_NULL(t.alternatives);
ASSERT_NOT_NULL(t.contents);
ASSERT_EQ(1, t.alternatives[0].len);
ASSERT_EQ(
PARSE_QUANTIFIER_PLUS, t.alternatives[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_WILDCARD, t.alternatives[0].contents[0].type);
ASSERT_EQ(1, t.contents[0].count);
ASSERT_EQ(PARSE_QUANTIFIER_PLUS, t.contents[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_WILDCARD, t.contents[0].contents[0].type);
parse_free_tree_children(&t);
}
@@ -243,12 +227,11 @@ static void dot_question_mark_is_parsed_as_qmrk_quantified_wildcard(void)
const int result = PARSE_EXPR_STRING(".?", &t);
ASSERT_NE(-1, result);
ASSERT_EQ(1, t.count);
ASSERT_NOT_NULL(t.alternatives);
ASSERT_NOT_NULL(t.contents);
ASSERT_EQ(1, t.alternatives[0].len);
ASSERT_EQ(
PARSE_QUANTIFIER_QMRK, t.alternatives[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_WILDCARD, t.alternatives[0].contents[0].type);
ASSERT_EQ(1, t.contents[0].count);
ASSERT_EQ(PARSE_QUANTIFIER_QMARK, t.contents[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_WILDCARD, t.contents[0].contents[0].type);
parse_free_tree_children(&t);
}
@@ -259,16 +242,15 @@ static void a_in_brackets_is_parsed_as_class_containing_only_a(void)
const int result = PARSE_EXPR_STRING("[a]", &t);
ASSERT_NE(-1, result);
ASSERT_EQ(1, t.count);
ASSERT_NOT_NULL(t.alternatives);
ASSERT_NOT_NULL(t.contents);
ASSERT_EQ(1, t.alternatives[0].len);
ASSERT_EQ(
PARSE_QUANTIFIER_NONE, t.alternatives[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_CLASS, t.alternatives[0].contents[0].type);
ASSERT_FALSE(t.alternatives[0].contents[0].class.negated);
ASSERT_EQ(1, t.alternatives[0].contents[0].class.count);
ASSERT_NOT_NULL(t.alternatives[0].contents[0].class.contents);
ASSERT_EQ('a', t.alternatives[0].contents[0].class.contents[0]);
ASSERT_EQ(1, t.contents[0].count);
ASSERT_EQ(PARSE_QUANTIFIER_NONE, t.contents[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_CLASS, t.contents[0].contents[0].type);
ASSERT_FALSE(t.contents[0].contents[0].class.negated);
ASSERT_EQ(1, t.contents[0].contents[0].class.count);
ASSERT_NOT_NULL(t.contents[0].contents[0].class.contents);
ASSERT_EQ('a', t.contents[0].contents[0].class.contents[0]);
parse_free_tree_children(&t);
}
@@ -279,16 +261,15 @@ static void caret_a_in_brackets_parses_as_negated_class(void)
const int result = PARSE_EXPR_STRING("[^a]", &t);
ASSERT_NE(-1, result);
ASSERT_EQ(1, t.count);
ASSERT_NOT_NULL(t.alternatives);
ASSERT_NOT_NULL(t.contents);
ASSERT_EQ(1, t.alternatives[0].len);
ASSERT_EQ(
PARSE_QUANTIFIER_NONE, t.alternatives[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_CLASS, t.alternatives[0].contents[0].type);
ASSERT_TRUE(t.alternatives[0].contents[0].class.negated);
ASSERT_EQ(1, t.alternatives[0].contents[0].class.count);
ASSERT_NOT_NULL(t.alternatives[0].contents[0].class.contents);
ASSERT_EQ('a', t.alternatives[0].contents[0].class.contents[0]);
ASSERT_EQ(1, t.contents[0].count);
ASSERT_EQ(PARSE_QUANTIFIER_NONE, t.contents[0].contents[0].quantifier);
ASSERT_EQ(PARSE_TERM_CLASS, t.contents[0].contents[0].type);
ASSERT_TRUE(t.contents[0].contents[0].class.negated);
ASSERT_EQ(1, t.contents[0].contents[0].class.count);
ASSERT_NOT_NULL(t.contents[0].contents[0].class.contents);
ASSERT_EQ('a', t.contents[0].contents[0].class.contents[0]);
parse_free_tree_children(&t);
}