END_TEST START_TEST(test_get_bare_jid) { assert_string_equal_free("foo@bar", jabber_get_bare_jid("foo@bar")); assert_string_equal_free("foo@bar", jabber_get_bare_jid("foo@bar/baz")); assert_string_equal_free("bar", jabber_get_bare_jid("bar")); assert_string_equal_free("bar", jabber_get_bare_jid("bar/baz")); }
END_TEST START_TEST(test_util_text_strip_mnemonic) { assert_string_equal_free("", purple_text_strip_mnemonic("")); assert_string_equal_free("foo", purple_text_strip_mnemonic("foo")); assert_string_equal_free("foo", purple_text_strip_mnemonic("_foo")); }
END_TEST START_TEST(test_strip_prefixes) { const char *xml_doc = "<message xmlns='jabber:client' from='[email protected]/resource' to='*****@*****.**' type='chat' id='purple'>" "<cha:active xmlns:cha='http://jabber.org/protocol/chatstates'/>" "<body>xvlc xvlc</body>" "<im:html xmlns:im='http://jabber.org/protocol/xhtml-im'>" "<xht:body xmlns:xht='http://www.w3.org/1999/xhtml'>" "<xht:p>xvlc <xht:span style='font-weight: bold;'>xvlc</xht:span></xht:p>" "</xht:body>" "</im:html>" "</message>"; const char *out = "<message xmlns='jabber:client' from='[email protected]/resource' to='*****@*****.**' type='chat' id='purple'>" "<active xmlns:cha='http://jabber.org/protocol/chatstates' xmlns='http://jabber.org/protocol/chatstates'/>" "<body>xvlc xvlc</body>" "<html xmlns:im='http://jabber.org/protocol/xhtml-im' xmlns='http://jabber.org/protocol/xhtml-im'>" "<body xmlns:xht='http://www.w3.org/1999/xhtml' xmlns='http://www.w3.org/1999/xhtml'>" "<p>xvlc <span style='font-weight: bold;'>xvlc</span></p>" "</body>" "</html>" "</message>"; char *str; PurpleXmlNode *xml; xml = purple_xmlnode_from_str(xml_doc, -1); fail_if(xml == NULL, "Failed to parse XML"); purple_xmlnode_strip_prefixes(xml); str = purple_xmlnode_to_str(xml, NULL); assert_string_equal_free(out, str); purple_xmlnode_free(xml); }
END_TEST START_TEST(test_util_base64_encode) { assert_string_equal_free("Zm9ydHktdHdvAA==", purple_base64_encode("forty-two", 10)); }