diff options
| author | Marvin W <git@larma.de> | 2026-10-04 17:49:16 +0200 |
|---|---|---|
| committer | Marvin W <git@larma.de> | 2026-10-23 17:01:41 +0200 |
| commit | 630b1368331ef0034b343bd2f00b116c8cd90391 (patch) | |
| tree | 30afc5a4471d084d7f074fce24df9a8d945b5084 /xmpp-vala/tests | |
| parent | ec4ca2a4642552b8424e7703840cd37e371e9e00 (diff) | |
Fix some warnings
Diffstat (limited to 'xmpp-vala/tests')
| -rw-r--r-- | xmpp-vala/tests/color.vala | 6 | ||||
| -rw-r--r-- | xmpp-vala/tests/stanza.vala | 48 | ||||
| -rw-r--r-- | xmpp-vala/tests/testcase.vala | 13 |
3 files changed, 43 insertions, 24 deletions
diff --git a/xmpp-vala/tests/color.vala b/xmpp-vala/tests/color.vala index ded67d53..a00710c5 100644 --- a/xmpp-vala/tests/color.vala +++ b/xmpp-vala/tests/color.vala @@ -39,9 +39,9 @@ class ColorTest : Gee.TestCase { public void test_rgb_to_angle() { string[] colors = {"e57373", "f06292", "ba68c8", "9575cd", "7986cb", "64b5f6", "4fc3f7", "4dd0e1", "4db6ac", "81c784", "aed581", "dce775", "fff176", "ffd54f", "ffb74d", "ff8a65"}; foreach(string hex_color in colors) { - uint8 r = (uint8) ((double) hex_color.substring(0, 2).to_long(null, 16)); - uint8 g = (uint8) ((double) hex_color.substring(2, 2).to_long(null, 16)); - uint8 b = (uint8) ((double) hex_color.substring(4, 2).to_long(null, 16)); + uint8 r = (uint8) ((double) long.parse(hex_color.substring(0, 2), 16)); + uint8 g = (uint8) ((double) long.parse(hex_color.substring(2, 2), 16)); + uint8 b = (uint8) ((double) long.parse(hex_color.substring(4, 2), 16)); //print(@"$hex_color, $r, $g, $b, $(ConsistentColor.rgb_to_angle(r, g, b))\n"); } } diff --git a/xmpp-vala/tests/stanza.vala b/xmpp-vala/tests/stanza.vala index 42e19f9a..b573995f 100644 --- a/xmpp-vala/tests/stanza.vala +++ b/xmpp-vala/tests/stanza.vala @@ -21,11 +21,15 @@ class StanzaTest : Gee.TestCase { .put_node(new StanzaNode.build("testbb", "ns3_uri") .add_self_xmlns()); - var xml1 = node1.to_xml(); - var node2 = yield new StanzaReader.for_string(xml1).read_node(); - fail_if_not(node1.equals(node2)); - fail_if_not_eq_str(node1.to_string(), node2.to_string()); - cb(); + try { + var xml1 = node1.to_xml(); + var node2 = yield new StanzaReader.for_string(xml1).read_node(); + fail_if_not(node1.equals(node2)); + fail_if_not_eq_str(node1.to_string(), node2.to_string()); + cb(); + } catch (GLib.Error e) { + cb(e); + } } private async void test_typical_stream(Gee.TestFinishedCallback cb) { @@ -55,12 +59,16 @@ class StanzaTest : Gee.TestCase { .put_node(new StanzaNode.build("body") .put_node(new StanzaNode.text(" I'll send a friar with speed, to Mantua, with my letters to thy lord."))); - var reader = new StanzaReader.for_string(stream); - fail_if_not_eq_node(root_node_cmp, yield reader.read_root_node()); - fail_if_not_eq_node(node_cmp, yield reader.read_node()); - yield reader.read_node(); - yield fail_if_not_end_of_stream(reader); - cb(); + try { + var reader = new StanzaReader.for_string(stream); + fail_if_not_eq_node(root_node_cmp, yield reader.read_root_node()); + fail_if_not_eq_node(node_cmp, yield reader.read_node()); + yield reader.read_node(); + yield fail_if_not_end_of_stream(reader); + cb(); + } catch (GLib.Error e) { + cb(e); + } } private async void fail_if_not_end_of_stream(StanzaReader reader) { @@ -105,13 +113,17 @@ class StanzaTest : Gee.TestCase { .put_node(new StanzaNode.build("required", "urn:ietf:params:xml:ns:xmpp-bind"))); var node2_cmp = new StanzaNode.build("r", "http://jabber.org/protocol/ack"); - var reader = new StanzaReader.for_string(stream); - fail_if_not_eq_node(root_node_cmp, yield reader.read_root_node()); - fail_if_not_eq_node(node_cmp, yield reader.read_node()); - fail_if_not_eq_node(node2_cmp, yield reader.read_node()); - yield reader.read_node(); - yield fail_if_not_end_of_stream(reader); - cb(); + try { + var reader = new StanzaReader.for_string(stream); + fail_if_not_eq_node(root_node_cmp, yield reader.read_root_node()); + fail_if_not_eq_node(node_cmp, yield reader.read_node()); + fail_if_not_eq_node(node2_cmp, yield reader.read_node()); + yield reader.read_node(); + yield fail_if_not_end_of_stream(reader); + cb(); + } catch (GLib.Error e) { + cb(e); + } } private void test_encoded_val() { diff --git a/xmpp-vala/tests/testcase.vala b/xmpp-vala/tests/testcase.vala index 178b6353..10da78f6 100644 --- a/xmpp-vala/tests/testcase.vala +++ b/xmpp-vala/tests/testcase.vala @@ -62,7 +62,7 @@ public abstract class Gee.TestCase : Object { namespace Gee { public delegate void TestMethod (); - public delegate void TestFinishedCallback (); + public delegate void TestFinishedCallback (GLib.Error? error = null); public delegate void AsyncTestMethod (TestFinishedCallback cb); } @@ -128,8 +128,15 @@ private class Gee.TestAsyncAdaptor : Object, TestAdaptor { main_loop.run (); } - public void finish () { - Idle.add (() => { main_loop.quit (); return false; }); + public void finish (GLib.Error? error = null) { + Idle.add(() => { + main_loop.quit(); + if (error != null) { + Test.fail(); + Test.message("Error: %s", error.message); + } + return false; + }); } public bool finish_timeout () { |
