From d4f24630f3a454a0aecaa17ee2667ad1bce367f5 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 9 Jan 2009 17:36:28 +0000 Subject: Add test for previous commit --- tests/test_util_stanza.lua | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tests/test_util_stanza.lua (limited to 'tests/test_util_stanza.lua') diff --git a/tests/test_util_stanza.lua b/tests/test_util_stanza.lua new file mode 100644 index 00000000..897dab95 --- /dev/null +++ b/tests/test_util_stanza.lua @@ -0,0 +1,7 @@ + +function deserialize(deserialize, st) + local stanza = st.stanza("message", { a = "a" }); + + local stanza2 = deserialize(st.preserialize(stanza)); + assert_is(stanza2.last_add, "Deserialized stanza is missing last_add for adding child tags"); +end -- cgit v1.2.3 From 365368ef5272c34f83f32a77585e10acf174a175 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 9 Jan 2009 17:44:59 +0000 Subject: Add more tests for util/stanza.lua serialization routines --- tests/test_util_stanza.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/test_util_stanza.lua') diff --git a/tests/test_util_stanza.lua b/tests/test_util_stanza.lua index 897dab95..f4c4810a 100644 --- a/tests/test_util_stanza.lua +++ b/tests/test_util_stanza.lua @@ -1,7 +1,20 @@ +function preserialize(preserialize, st) + local stanza = st.stanza("message", { a = "a" }); + local stanza2 = preserialize(stanza); + assert_is(stanza2 and stanza.name, "preserialize returns a stanza"); + assert_is_not(stanza2.tags, "Preserialized stanza has no tag list"); + assert_is_not(stanza2.last_add, "Preserialized stanza has no last_add marker"); + assert_is_not(getmetatable(stanza2), "Preserialized stanza has no metatable"); +end + function deserialize(deserialize, st) local stanza = st.stanza("message", { a = "a" }); local stanza2 = deserialize(st.preserialize(stanza)); + assert_is(stanza2 and stanza.name, "deserialize returns a stanza"); assert_is(stanza2.last_add, "Deserialized stanza is missing last_add for adding child tags"); + assert_table(stanza2.attr, "Deserialized stanza has attributes"); + assert_equal(stanza2.attr.a, "a", "Deserialized stanza retains attributes"); + assert_table(getmetatable(stanza2), "Deserialized stanza has metatable"); end -- cgit v1.2.3