Skip to content

Commit c7f5d86

Browse files
committed
test: update tests to reflect new select parsing rules
- update gumbo tests - pin to html5lib/html5lib-tests#178 branch
1 parent a34191f commit c7f5d86

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

gumbo-parser/test/parser.cc

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,17 +1017,29 @@ TEST_F(GumboParserTest, ComplicatedSelect) {
10171017

10181018
GumboNode* body;
10191019
GetAndAssertBody(root_, &body);
1020-
ASSERT_EQ(2, GetChildCount(body));
1020+
ASSERT_EQ(1, GetChildCount(body));
10211021

10221022
GumboNode* select = GetChild(body, 0);
10231023
ASSERT_EQ(GUMBO_NODE_ELEMENT, select->type);
10241024
EXPECT_EQ(GUMBO_TAG_SELECT, GetTag(select));
1025-
ASSERT_EQ(1, GetChildCount(select));
1025+
ASSERT_EQ(2, GetChildCount(select));
1026+
1027+
GumboNode* div = GetChild(select, 0);
1028+
ASSERT_EQ(GUMBO_NODE_ELEMENT, div->type);
1029+
EXPECT_EQ(GUMBO_TAG_DIV, GetTag(div));
1030+
1031+
GumboVector* attributes = &div->v.element.attributes;
1032+
ASSERT_EQ(1, attributes->length);
10261033

1027-
GumboNode* optgroup = GetChild(select, 0);
1034+
GumboAttribute* klass = static_cast<GumboAttribute*>(attributes->data[0]);
1035+
EXPECT_EQ(GUMBO_ATTR_NAMESPACE_NONE, klass->attr_namespace);
1036+
EXPECT_STREQ("class", klass->name);
1037+
EXPECT_STREQ("foo", klass->value);
1038+
1039+
GumboNode* optgroup = GetChild(select, 1);
10281040
ASSERT_EQ(GUMBO_NODE_ELEMENT, optgroup->type);
10291041
EXPECT_EQ(GUMBO_TAG_OPTGROUP, GetTag(optgroup));
1030-
ASSERT_EQ(1, GetChildCount(optgroup));
1042+
ASSERT_EQ(2, GetChildCount(optgroup));
10311043

10321044
GumboNode* option = GetChild(optgroup, 0);
10331045
ASSERT_EQ(GUMBO_NODE_ELEMENT, option->type);
@@ -1038,7 +1050,7 @@ TEST_F(GumboParserTest, ComplicatedSelect) {
10381050
ASSERT_EQ(GUMBO_NODE_TEXT, text->type);
10391051
EXPECT_STREQ("Option", text->v.text.text);
10401052

1041-
GumboNode* input = GetChild(body, 1);
1053+
GumboNode* input = GetChild(optgroup, 1);
10421054
ASSERT_EQ(GUMBO_NODE_ELEMENT, input->type);
10431055
EXPECT_EQ(GUMBO_TAG_INPUT, GetTag(input));
10441056
ASSERT_EQ(0, GetChildCount(input));
@@ -1051,12 +1063,17 @@ TEST_F(GumboParserTest, DoubleSelect) {
10511063
GetAndAssertBody(root_, &body);
10521064
ASSERT_EQ(2, GetChildCount(body));
10531065

1054-
GumboNode* select = GetChild(body, 0);
1055-
ASSERT_EQ(GUMBO_NODE_ELEMENT, select->type);
1056-
EXPECT_EQ(GUMBO_TAG_SELECT, GetTag(select));
1057-
ASSERT_EQ(0, GetChildCount(select));
1066+
GumboNode* select1 = GetChild(body, 0);
1067+
ASSERT_EQ(GUMBO_NODE_ELEMENT, select1->type);
1068+
EXPECT_EQ(GUMBO_TAG_SELECT, GetTag(select1));
1069+
ASSERT_EQ(0, GetChildCount(select1));
10581070

1059-
GumboNode* div = GetChild(body, 1);
1071+
GumboNode* select2 = GetChild(body, 1);
1072+
ASSERT_EQ(GUMBO_NODE_ELEMENT, select2->type);
1073+
EXPECT_EQ(GUMBO_TAG_SELECT, GetTag(select2));
1074+
ASSERT_EQ(1, GetChildCount(select2));
1075+
1076+
GumboNode* div = GetChild(select2, 0);
10601077
ASSERT_EQ(GUMBO_NODE_ELEMENT, div->type);
10611078
EXPECT_EQ(GUMBO_TAG_DIV, GetTag(div));
10621079
ASSERT_EQ(0, GetChildCount(div));
@@ -1067,19 +1084,19 @@ TEST_F(GumboParserTest, InputInSelect) {
10671084

10681085
GumboNode* body;
10691086
GetAndAssertBody(root_, &body);
1070-
ASSERT_EQ(3, GetChildCount(body));
1087+
ASSERT_EQ(1, GetChildCount(body));
10711088

10721089
GumboNode* select = GetChild(body, 0);
10731090
ASSERT_EQ(GUMBO_NODE_ELEMENT, select->type);
10741091
EXPECT_EQ(GUMBO_TAG_SELECT, GetTag(select));
1075-
ASSERT_EQ(0, GetChildCount(select));
1092+
ASSERT_EQ(2, GetChildCount(select));
10761093

1077-
GumboNode* input = GetChild(body, 1);
1094+
GumboNode* input = GetChild(select, 0);
10781095
ASSERT_EQ(GUMBO_NODE_ELEMENT, input->type);
10791096
EXPECT_EQ(GUMBO_TAG_INPUT, GetTag(input));
10801097
ASSERT_EQ(0, GetChildCount(input));
10811098

1082-
GumboNode* div = GetChild(body, 2);
1099+
GumboNode* div = GetChild(select, 1);
10831100
ASSERT_EQ(GUMBO_NODE_ELEMENT, div->type);
10841101
EXPECT_EQ(GUMBO_TAG_DIV, GetTag(div));
10851102
ASSERT_EQ(0, GetChildCount(div));

0 commit comments

Comments
 (0)