Mercurial > prosody-hg
comparison tests/test_util_jid.lua @ 2821:c0981e104abc
tests: Add tests for util.jid.join()
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 27 Nov 2009 17:41:52 +0000 |
| parents | 841d61be198f |
| children | b7049746bd29 |
comparison
equal
deleted
inserted
replaced
| 2820:0ad29a5485d6 | 2821:c0981e104abc |
|---|---|
| 4 -- | 4 -- |
| 5 -- This project is MIT/X11 licensed. Please see the | 5 -- This project is MIT/X11 licensed. Please see the |
| 6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
| 7 -- | 7 -- |
| 8 | 8 |
| 9 function join(join) | |
| 10 assert_equal(join("a", "b", "c"), "a@b/c", "builds full JID"); | |
| 11 assert_equal(join("a", "b", nil), "a@b", "builds bare JID"); | |
| 12 assert_equal(join(nil, "b", "c"), "b/c", "builds full host JID"); | |
| 13 assert_equal(join(nil, "b", nil), "b", "builds bare host JID"); | |
| 14 assert_equal(join(nil, nil, nil), nil, "invalid JID is nil"); | |
| 15 assert_equal(join("a", nil, nil), nil, "invalid JID is nil"); | |
| 16 assert_equal(join(nil, nil, "c"), nil, "invalid JID is nil"); | |
| 17 assert_equal(join("a", nil, "c"), nil, "invalid JID is nil"); | |
| 18 end | |
| 9 | 19 |
| 10 | 20 |
| 11 function split(split) | 21 function split(split) |
| 12 function test(input_jid, expected_node, expected_server, expected_resource) | 22 function test(input_jid, expected_node, expected_server, expected_resource) |
| 13 local rnode, rserver, rresource = split(input_jid); | 23 local rnode, rserver, rresource = split(input_jid); |
| 41 assert_equal(bare("user@@"), nil, "invalid JID is nil"); | 51 assert_equal(bare("user@@"), nil, "invalid JID is nil"); |
| 42 assert_equal(bare("user@@host"), nil, "invalid JID is nil"); | 52 assert_equal(bare("user@@host"), nil, "invalid JID is nil"); |
| 43 assert_equal(bare("user@@host/resource"), nil, "invalid JID is nil"); | 53 assert_equal(bare("user@@host/resource"), nil, "invalid JID is nil"); |
| 44 assert_equal(bare("user@host/"), nil, "invalid JID is nil"); | 54 assert_equal(bare("user@host/"), nil, "invalid JID is nil"); |
| 45 end | 55 end |
| 56 |
