aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_util_jid.lua
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2008-11-23 20:44:48 +0100
committerTobias Markmann <tm@ayena.de>2008-11-23 20:44:48 +0100
commit560094822d86f10450567785544cfcca61dd8a3b (patch)
treec2737280276b8ec3642cae5ae644e81da621be04 /tests/test_util_jid.lua
parent3bc6fdb526dec6b56dab9208461d5b2f4db08006 (diff)
parent6db47b60f4574bc8e5a34eacac8a67ccd52107dd (diff)
downloadprosody-560094822d86f10450567785544cfcca61dd8a3b.tar.gz
prosody-560094822d86f10450567785544cfcca61dd8a3b.zip
Merging with main branch.
Diffstat (limited to 'tests/test_util_jid.lua')
-rw-r--r--tests/test_util_jid.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_util_jid.lua b/tests/test_util_jid.lua
index 1dbd72b7..7a616008 100644
--- a/tests/test_util_jid.lua
+++ b/tests/test_util_jid.lua
@@ -11,4 +11,24 @@ function split(split)
test("server", nil, "server", nil );
test("server/resource", nil, "server", "resource" );
test(nil, nil, nil , nil );
+
+ test("node@/server", nil, nil, nil , nil );
+end
+
+function bare(bare)
+ assert_equal(bare("user@host"), "user@host", "bare JID remains bare");
+ assert_equal(bare("host"), "host", "Host JID remains host");
+ assert_equal(bare("host/resource"), "host", "Host JID with resource becomes host");
+ assert_equal(bare("user@host/resource"), "user@host", "user@host JID with resource becomes user@host");
+ assert_equal(bare("user@/resource"), nil, "invalid JID is nil");
+ assert_equal(bare("@/resource"), nil, "invalid JID is nil");
+ assert_equal(bare("@/"), nil, "invalid JID is nil");
+ assert_equal(bare("/"), nil, "invalid JID is nil");
+ assert_equal(bare(""), nil, "invalid JID is nil");
+ assert_equal(bare("@"), nil, "invalid JID is nil");
+ assert_equal(bare("user@"), nil, "invalid JID is nil");
+ assert_equal(bare("user@@"), nil, "invalid JID is nil");
+ assert_equal(bare("user@@host"), nil, "invalid JID is nil");
+ assert_equal(bare("user@@host/resource"), nil, "invalid JID is nil");
+ assert_equal(bare("user@host/"), nil, "invalid JID is nil");
end