aboutsummaryrefslogtreecommitdiff
path: root/libdino/tests/jid.vala
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-11-14 17:00:09 +0100
committerfiaxh <git@lightrise.org>2020-11-14 17:00:09 +0100
commitb8d216a0575fbdc5a8eeeed07a1aeda8bd83ffea (patch)
tree7f9bc7265f1f286cb1226e8a1e2b8a2b92700cff /libdino/tests/jid.vala
parent2a775bcfb9365058376bd45dd88f5bf164dec688 (diff)
downloaddino-b8d216a0575fbdc5a8eeeed07a1aeda8bd83ffea.tar.gz
dino-b8d216a0575fbdc5a8eeeed07a1aeda8bd83ffea.zip
Add a WeakMap implementation + tests
Diffstat (limited to 'libdino/tests/jid.vala')
-rw-r--r--libdino/tests/jid.vala39
1 files changed, 39 insertions, 0 deletions
diff --git a/libdino/tests/jid.vala b/libdino/tests/jid.vala
new file mode 100644
index 00000000..08ec5c3a
--- /dev/null
+++ b/libdino/tests/jid.vala
@@ -0,0 +1,39 @@
+using Dino.Entities;
+
+namespace Dino.Test {
+
+class JidTest : Gee.TestCase {
+
+ public JidTest() {
+ base("Jid");
+ add_test("parse", test_parse);
+ add_test("components", test_components);
+ add_test("with_res", test_with_res);
+ }
+
+ private void test_parse() {
+ Jid jid = new Jid("user@example.com/res");
+ fail_if(jid.localpart != "user");
+ fail_if(jid.domainpart != "example.com");
+ fail_if(jid.resourcepart != "res");
+ fail_if(jid.to_string() != "user@example.com/res");
+ }
+
+ private void test_components() {
+ Jid jid = new Jid.components("user", "example.com", "res");
+ fail_if(jid.localpart != "user");
+ fail_if(jid.domainpart != "example.com");
+ fail_if(jid.resourcepart != "res");
+ fail_if(jid.to_string() != "user@example.com/res");
+ }
+
+ private void test_with_res() {
+ Jid jid = new Jid.with_resource("user@example.com", "res");
+ fail_if(jid.localpart != "user");
+ fail_if(jid.domainpart != "example.com");
+ fail_if(jid.resourcepart != "res");
+ fail_if(jid.to_string() != "user@example.com/res");
+ }
+}
+
+}