aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/tests/stanza.vala
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala/tests/stanza.vala')
-rw-r--r--xmpp-vala/tests/stanza.vala20
1 files changed, 20 insertions, 0 deletions
diff --git a/xmpp-vala/tests/stanza.vala b/xmpp-vala/tests/stanza.vala
index cd374912..fa1ccb41 100644
--- a/xmpp-vala/tests/stanza.vala
+++ b/xmpp-vala/tests/stanza.vala
@@ -7,6 +7,7 @@ class StanzaTest : Gee.TestCase {
add_async_test("node_one", (cb) => { test_node_one.begin(cb); });
add_async_test("typical_stream", (cb) => { test_typical_stream.begin(cb); });
add_async_test("ack_stream", (cb) => { test_ack_stream.begin(cb); });
+ add_test("get_attribute_(u)int", test_get_attribute_int);
}
private async void test_node_one(Gee.TestFinishedCallback cb) {
@@ -112,6 +113,25 @@ class StanzaTest : Gee.TestCase {
cb();
}
+ private void test_get_attribute_int() {
+ var stanza_node = new StanzaNode.build("test", "ns").add_self_xmlns().put_attribute("bar", "42");
+ assert(stanza_node.get_attribute_int("bar", -2) == 42);
+ assert(stanza_node.get_attribute_uint("bar", 3) == 42);
+
+ stanza_node = new StanzaNode.build("test", "ns").add_self_xmlns().put_attribute("bar", "-42");
+ assert(stanza_node.get_attribute_int("bar", -2) == -42);
+ assert(stanza_node.get_attribute_uint("bar", 3) == 3);
+
+ stanza_node = new StanzaNode.build("test", "ns").add_self_xmlns();
+ assert(stanza_node.get_attribute_int("bar", -2) == -2);
+ assert(stanza_node.get_attribute_uint("bar", 3) == 3);
+
+ stanza_node = new StanzaNode.build("test", "ns").add_self_xmlns().put_attribute("bar", "str");
+ assert(stanza_node.get_attribute_int("bar", -2) == -2);
+ assert(stanza_node.get_attribute_uint("bar", 3) == 3);
+
+ }
+
}
}