aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/tests/util.vala
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala/tests/util.vala')
-rw-r--r--xmpp-vala/tests/util.vala24
1 files changed, 24 insertions, 0 deletions
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));
+ });
+ }
+}
+
+}