Annotate

tests/test_util_stanza.lua @ 1061:8c5876378c6f

mod_posix: Fix for removing the pidfile on exit
author Matthew Wild <mwild1@gmail.com>
date Thu, 23 Apr 2009 21:34:03 +0100
parent 682:dedd19e9d4b3
child 1522:569d58d21612
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
682
dedd19e9d4b3 Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents: 681
diff changeset
1
dedd19e9d4b3 Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents: 681
diff changeset
2 function preserialize(preserialize, st)
dedd19e9d4b3 Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents: 681
diff changeset
3 local stanza = st.stanza("message", { a = "a" });
dedd19e9d4b3 Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents: 681
diff changeset
4 local stanza2 = preserialize(stanza);
dedd19e9d4b3 Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents: 681
diff changeset
5 assert_is(stanza2 and stanza.name, "preserialize returns a stanza");
dedd19e9d4b3 Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents: 681
diff changeset
6 assert_is_not(stanza2.tags, "Preserialized stanza has no tag list");
dedd19e9d4b3 Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents: 681
diff changeset
7 assert_is_not(stanza2.last_add, "Preserialized stanza has no last_add marker");
dedd19e9d4b3 Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents: 681
diff changeset
8 assert_is_not(getmetatable(stanza2), "Preserialized stanza has no metatable");
dedd19e9d4b3 Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents: 681
diff changeset
9 end
681
686b73503ce8 Add test for previous commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10
686b73503ce8 Add test for previous commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 function deserialize(deserialize, st)
686b73503ce8 Add test for previous commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 local stanza = st.stanza("message", { a = "a" });
686b73503ce8 Add test for previous commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13
686b73503ce8 Add test for previous commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 local stanza2 = deserialize(st.preserialize(stanza));
682
dedd19e9d4b3 Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents: 681
diff changeset
15 assert_is(stanza2 and stanza.name, "deserialize returns a stanza");
681
686b73503ce8 Add test for previous commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 assert_is(stanza2.last_add, "Deserialized stanza is missing last_add for adding child tags");
682
dedd19e9d4b3 Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents: 681
diff changeset
17 assert_table(stanza2.attr, "Deserialized stanza has attributes");
dedd19e9d4b3 Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents: 681
diff changeset
18 assert_equal(stanza2.attr.a, "a", "Deserialized stanza retains attributes");
dedd19e9d4b3 Add more tests for util/stanza.lua serialization routines
Matthew Wild <mwild1@gmail.com>
parents: 681
diff changeset
19 assert_table(getmetatable(stanza2), "Deserialized stanza has metatable");
681
686b73503ce8 Add test for previous commit
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 end