Skip to content

Commit e84d384

Browse files
committed
tests: add tests for invalid and incomplete list BB codes
1 parent 6a6a643 commit e84d384

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/components/bbcode/ListBBCode.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,37 @@ TEST_CASE("ListBBCode")
122122
REQUIRE( text == value );
123123
}
124124
}
125+
126+
SECTION("invalid code tests")
127+
{
128+
SECTION("nested list starts before item [*] of outer list")
129+
{
130+
ListBBCode list("list", true);
131+
std::string text = "I heard you like lists, so [list]I [list][*]made[*]a[*]list[/list][*]inside[*]your list.[/list]";
132+
const std::string expected = text;
133+
list.applyToText(text);
134+
// Code is wrong, so not HTML code is generated.
135+
REQUIRE( text == expected );
136+
}
137+
138+
SECTION("nested list starts before item [*] of outer list, three level variant")
139+
{
140+
ListBBCode list("list", true);
141+
std::string text = "I heard you like lists, so [list][*]I [list][list][*]made[*]a[/list][*]list[/list][*]inside[*]your list.[/list]";
142+
const std::string expected = text;
143+
list.applyToText(text);
144+
// Code is wrong, so not HTML code is generated.
145+
REQUIRE( text == expected );
146+
}
147+
148+
SECTION("nested lists where outer list has no end tag")
149+
{
150+
ListBBCode list("list", true);
151+
std::string text = "I heard you like lists, so [list][*]I [list][*]made[*]a[*]list[/list]inside your list.";
152+
const std::string expected = "I heard you like lists, so [list][*]I <ul><li>made</li><li>a</li><li>list</li></ul>inside your list.";
153+
list.applyToText(text);
154+
// Code is incomplete, so not HTML code is generated for the outer list.
155+
REQUIRE( text == expected );
156+
}
157+
}
125158
}

0 commit comments

Comments
 (0)