aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/tests/common.vala
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2019-12-22 04:10:53 +0100
committerMarvin W <git@larma.de>2019-12-23 16:58:53 +0100
commita0a956ee0878d24bd06be7f5d75dc4ccd4e7901d (patch)
treecbb079649066c2001b6d6881137108e70eed9d3f /xmpp-vala/tests/common.vala
parent3218dc0211ac717230fe03fad82681a626d968b5 (diff)
downloaddino-a0a956ee0878d24bd06be7f5d75dc4ccd4e7901d.tar.gz
dino-a0a956ee0878d24bd06be7f5d75dc4ccd4e7901d.zip
Properly check Jids everywhere
Diffstat (limited to 'xmpp-vala/tests/common.vala')
-rw-r--r--xmpp-vala/tests/common.vala8
1 files changed, 8 insertions, 0 deletions
diff --git a/xmpp-vala/tests/common.vala b/xmpp-vala/tests/common.vala
index b91bbf7c..c616d2e7 100644
--- a/xmpp-vala/tests/common.vala
+++ b/xmpp-vala/tests/common.vala
@@ -5,6 +5,7 @@ int main(string[] args) {
GLib.Test.set_nonfatal_assertions();
TestSuite.get_root().add_suite(new Xmpp.Test.StanzaTest().get_suite());
TestSuite.get_root().add_suite(new Xmpp.Test.UtilTest().get_suite());
+ TestSuite.get_root().add_suite(new Xmpp.Test.JidTest().get_suite());
return GLib.Test.run();
}
@@ -74,6 +75,13 @@ bool fail_if_not_eq_str(string? left, string? right, string? reason = null) {
return fail_if_not(!nullcheck && left == right, @"$(reason + ": " ?? "")$left != $right");
}
+bool fail_if_eq_str(string? left, string? right, string? reason = null) {
+ bool nullcheck = (left == null && right != null) || (left != null && right == null);
+ if (left == null) left = "(null)";
+ if (right == null) right = "(null)";
+ return fail_if(!nullcheck && left == right, @"$(reason + ": " ?? "")$left == $right");
+}
+
bool fail_if_not_eq_uint8_arr(uint8[] left, uint8[] right, string? reason = null) {
if (fail_if_not_eq_int(left.length, right.length, @"$(reason + ": " ?? "")array length not equal")) return true;
return fail_if_not_eq_str(Base64.encode(left), Base64.encode(right), reason);