@@ -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