Changeset

682:dedd19e9d4b3

Add more tests for util/stanza.lua serialization routines
author Matthew Wild <mwild1@gmail.com>
date Fri, 09 Jan 2009 17:44:59 +0000
parents 681:686b73503ce8
children 683:7428244a82a6
files tests/test_util_stanza.lua
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test_util_stanza.lua	Fri Jan 09 17:36:28 2009 +0000
+++ b/tests/test_util_stanza.lua	Fri Jan 09 17:44:59 2009 +0000
@@ -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