[telepathy-gabble/master] add test-caps-hash.c
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Thu Jul 23 08:07:09 PDT 2009
---
tests/test-caps-hash.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+), 0 deletions(-)
create mode 100644 tests/test-caps-hash.c
diff --git a/tests/test-caps-hash.c b/tests/test-caps-hash.c
new file mode 100644
index 0000000..28b6dd1
--- /dev/null
+++ b/tests/test-caps-hash.c
@@ -0,0 +1,46 @@
+#include "config.h"
+
+#include "src/caps-hash.h"
+#include "src/util.h"
+
+static gboolean
+check_hash (LmMessage *stanza,
+ const gchar *expected)
+{
+ gchar *hash;
+
+ hash = caps_hash_compute_from_lm_node (stanza->node);
+ g_assert (!tp_strdiff (hash, expected));
+ lm_message_unref (stanza);
+ g_free (hash);
+ return TRUE;
+}
+
+static gboolean
+test_simple (void)
+{
+ /* Simple example from XEP-0115 */
+ LmMessage *stanza = lm_message_build ("badger", LM_MESSAGE_TYPE_IQ,
+ '(', "identity", "",
+ '@', "category", "client",
+ '@', "name", "Exodus 0.9.1",
+ '@', "type", "pc",
+ ')',
+ '(', "feature", "", '@', "var", "http://jabber.org/protocol/disco#info", ')',
+ '(', "feature", "", '@', "var", "http://jabber.org/protocol/disco#items", ')',
+ '(', "feature", "", '@', "var", "http://jabber.org/protocol/muc", ')',
+ '(', "feature", "", '@', "var", "http://jabber.org/protocol/caps", ')',
+ ')',
+ NULL);
+
+ return check_hash (stanza, "QgayPKawpkPSDYmwT/WM94uAlu0=");
+}
+
+int
+main (void)
+{
+ g_type_init ();
+ g_assert (test_simple ());
+
+ return 0;
+}
--
1.5.6.5
More information about the telepathy-commits
mailing list