From e6f20d3c0fd4ba8696a4410a366741c9b9f3562d Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Fri, 22 Nov 2013 21:00:32 +0100 Subject: Implement IRC format to xhtml-im conversion The generated XML is very verbose because each IRC formatting tag makes us close a element and reopen it with the new style applied. However, this works quite well and is easy to implement. --- src/test.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/test.cpp') diff --git a/src/test.cpp b/src/test.cpp index 1f2d185..b33ff1d 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -84,6 +84,31 @@ int main() assert(xml_escape(unescaped) == "'coucou'<cc>/&"gaga""); assert(xml_unescape(xml_escape(unescaped)) == unescaped); + /** + * Colors conversion + */ + std::unique_ptr xhtml; + std::string cleaned_up; + + std::tie(cleaned_up, xhtml) = + irc_format_to_xhtmlim("normalboldunder-and-boldbold normal" + "5red,5default-on-red10,2cyan-on-blue"); + assert(xhtml); + assert(xhtml->to_string() == "normalboldunder-and-boldbold normalreddefault-on-redcyan-on-blue"); + assert(cleaned_up == "normalboldunder-and-boldbold normalreddefault-on-redcyan-on-blue"); + + std::tie(cleaned_up, xhtml) = irc_format_to_xhtmlim("normal"); + assert(!xhtml && cleaned_up == "normal"); + + std::tie(cleaned_up, xhtml) = irc_format_to_xhtmlim(""); + assert(xhtml && !xhtml->has_children() && cleaned_up.empty()); + + std::tie(cleaned_up, xhtml) = irc_format_to_xhtmlim(",a"); + assert(xhtml && !xhtml->has_children() && cleaned_up == "a"); + + std::tie(cleaned_up, xhtml) = irc_format_to_xhtmlim(","); + assert(xhtml && !xhtml->has_children() && cleaned_up.empty()); + /** * JID parsing */ -- cgit v1.2.3