Software /
code /
prosody
File
tests/test_util_stanza.lua @ 1298:4e0db19e5f1c
prosody: Add support for general 'interface' option which is used as the default network interface
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 04 Jun 2009 15:24:43 +0100 |
parent | 682:dedd19e9d4b3 |
child | 1522:569d58d21612 |
line wrap: on
line source
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