#include "catch.hpp" #include #include #include TEST_CASE("IRC colors parsing") { std::unique_ptr xhtml; std::string cleaned_up; std::tie(cleaned_up, xhtml) = irc_format_to_xhtmlim("bold"); CHECK(xhtml); CHECK(xhtml->to_string() == "bold"); std::tie(cleaned_up, xhtml) = irc_format_to_xhtmlim("normalboldunder-and-boldbold normal" "5red,5default-on-red10,2cyan-on-blue"); CHECK(xhtml); CHECK(xhtml->to_string() == "normalboldunder-and-boldbold normalreddefault-on-redcyan-on-blue"); CHECK(cleaned_up == "normalboldunder-and-boldbold normalreddefault-on-redcyan-on-blue"); std::tie(cleaned_up, xhtml) = irc_format_to_xhtmlim("normal"); CHECK_FALSE(xhtml); CHECK(cleaned_up == "normal"); std::tie(cleaned_up, xhtml) = irc_format_to_xhtmlim(""); CHECK(xhtml); CHECK(!xhtml->has_children()); CHECK(cleaned_up.empty()); std::tie(cleaned_up, xhtml) = irc_format_to_xhtmlim(",a"); CHECK(xhtml); CHECK(!xhtml->has_children()); CHECK(cleaned_up == "a"); std::tie(cleaned_up, xhtml) = irc_format_to_xhtmlim(","); CHECK(xhtml); CHECK(!xhtml->has_children()); CHECK(cleaned_up.empty()); std::tie(cleaned_up, xhtml) = irc_format_to_xhtmlim("[\x1D13dolphin-emu/dolphin\x1D] 03foo commented on #283 (Add support for the guide button to XInput): 02http://example.com"); CHECK(xhtml->to_string() == "[dolphin-emu/dolphin] foo commented on #283 (Add support for the guide button to XInput): http://example.com"); CHECK(cleaned_up == "[dolphin-emu/dolphin] foo commented on #283 (Add support for the guide button to XInput): http://example.com"); std::tie(cleaned_up, xhtml) = irc_format_to_xhtmlim("0e46ab by 03Pierre Dindon [090|091|040] 02http://example.net/Ojrh4P media: avoid pop-in effect when loading thumbnails by specifying an explicit size"); CHECK(cleaned_up == "0e46ab by Pierre Dindon [0|1|0] http://example.net/Ojrh4P media: avoid pop-in effect when loading thumbnails by specifying an explicit size"); CHECK(xhtml->to_string() == "0e46ab by Pierre Dindon [0|1|0] http://example.net/Ojrh4P media: avoid pop-in effect when loading thumbnails by specifying an explicit size"); std::tie(cleaned_up, xhtml) = irc_format_to_xhtmlim("test\ncoucou"); CHECK(cleaned_up == "test\ncoucou"); CHECK(xhtml->to_string() == "test
coucou"); }