diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-01-13 15:29:00 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-01-13 15:29:00 +0000 |
commit | 4dc4d175d135e293f48ed6a15f61b19c4dafe8d7 (patch) | |
tree | c4a1aeb92f7ccaccc8fd919d065d3add4c71c12d /tests | |
parent | bb7d8604f252ce84bdea1cb791114dfc40c5a958 (diff) | |
parent | 8b979ccaf40ae38dbeaa5e7a4edb2e6d760fdffa (diff) | |
download | prosody-4dc4d175d135e293f48ed6a15f61b19c4dafe8d7.tar.gz prosody-4dc4d175d135e293f48ed6a15f61b19c4dafe8d7.zip |
Automated merge with http://waqas.ath.cx:8000/
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test.lua | 3 | ||||
-rw-r--r-- | tests/test_util_stanza.lua | 20 |
2 files changed, 22 insertions, 1 deletions
diff --git a/tests/test.lua b/tests/test.lua index eb209219..bc1e1979 100644 --- a/tests/test.lua +++ b/tests/test.lua @@ -25,7 +25,8 @@ function run_all_tests() dotest "core.stanza_router" dotest "core.s2smanager" dotest "core.configmanager" - + dotest "util.stanza" + dosingletest("test_sasl.lua", "latin1toutf8"); end diff --git a/tests/test_util_stanza.lua b/tests/test_util_stanza.lua new file mode 100644 index 00000000..f4c4810a --- /dev/null +++ b/tests/test_util_stanza.lua @@ -0,0 +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 |