aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/tests
diff options
context:
space:
mode:
authorhrxi <hrrrxi@gmail.com>2019-09-01 18:18:25 +0200
committerfiaxh <fiaxh@users.noreply.github.com>2019-09-10 19:36:11 +0200
commitd5d305193ce527f1cc3022c406de35d9a85d4ccb (patch)
treed12efc741319a7d71c13f7bf6c2c7579d25fdabe /xmpp-vala/tests
parent9950742bf1903291c271619aea101b0e2f81d19c (diff)
downloaddino-d5d305193ce527f1cc3022c406de35d9a85d4ccb.tar.gz
dino-d5d305193ce527f1cc3022c406de35d9a85d4ccb.zip
Fix some warnings
Instances of `RegexError` are just asserted as `assert_not_reached` as they cannot really fail except for allocation failure if the given regex is valid.
Diffstat (limited to 'xmpp-vala/tests')
-rw-r--r--xmpp-vala/tests/common.vala1
-rw-r--r--xmpp-vala/tests/util.vala24
2 files changed, 25 insertions, 0 deletions
diff --git a/xmpp-vala/tests/common.vala b/xmpp-vala/tests/common.vala
index 01cc7d09..b91bbf7c 100644
--- a/xmpp-vala/tests/common.vala
+++ b/xmpp-vala/tests/common.vala
@@ -4,6 +4,7 @@ int main(string[] args) {
GLib.Test.init(ref 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());
return GLib.Test.run();
}
diff --git a/xmpp-vala/tests/util.vala b/xmpp-vala/tests/util.vala
new file mode 100644
index 00000000..9d893776
--- /dev/null
+++ b/xmpp-vala/tests/util.vala
@@ -0,0 +1,24 @@
+using Xmpp.Util;
+
+namespace Xmpp.Test {
+
+class UtilTest : Gee.TestCase {
+ public UtilTest() {
+ base("util");
+
+ add_hex_test(0x0, "");
+ add_hex_test(0x123abc, "123abc");
+ add_hex_test(0x0, "0x123abc");
+ add_hex_test(0xa, "A quick brown fox jumps over the lazy dog.");
+ add_hex_test(0xfeed, " FEED ME ");
+ }
+
+ private void add_hex_test(int expected, string str) {
+ string test_name = @"from_hex(\"$(str)\")";
+ add_test(test_name, () => {
+ fail_if_not_eq_int(expected, (int)from_hex(str));
+ });
+ }
+}
+
+}