summaryrefslogtreecommitdiff
path: root/src/test.cpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2013-11-22 21:00:32 +0100
committerFlorent Le Coz <louiz@louiz.org>2013-11-28 01:18:26 +0100
commite6f20d3c0fd4ba8696a4410a366741c9b9f3562d (patch)
tree0b34e42163fcb2b869e74fa11c4fb18cf5226b89 /src/test.cpp
parent31e18e49b699f606a8aeb1f529642a004781e704 (diff)
downloadbiboumi-e6f20d3c0fd4ba8696a4410a366741c9b9f3562d.tar.gz
biboumi-e6f20d3c0fd4ba8696a4410a366741c9b9f3562d.tar.bz2
biboumi-e6f20d3c0fd4ba8696a4410a366741c9b9f3562d.tar.xz
biboumi-e6f20d3c0fd4ba8696a4410a366741c9b9f3562d.zip
Implement IRC format to xhtml-im conversion
The generated XML is very verbose because each IRC formatting tag makes us close a <span/> element and reopen it with the new style applied. However, this works quite well and is easy to implement.
Diffstat (limited to 'src/test.cpp')
-rw-r--r--src/test.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test.cpp b/src/test.cpp
index 1f2d185..b33ff1d 100644
--- a/src/test.cpp
+++ b/src/test.cpp
@@ -85,6 +85,31 @@ int main()
assert(xml_unescape(xml_escape(unescaped)) == unescaped);
/**
+ * Colors conversion
+ */
+ std::unique_ptr<XmlNode> 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() == "<body xmlns='http://www.w3.org/1999/xhtml'>normal<span style='font-weight:bold;'>bold</span><span style='font-weight:bold;text-decoration:underline;'>under-and-bold</span><span style='font-weight:bold;'>bold</span> normal<span style='color:red;'>red</span><span style='background-color:red;'>default-on-red</span><span style='color:cyan;background-color:blue;'>cyan-on-blue</span></body>");
+ 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
*/
// Full JID