Comparison

tests/test_util_jid.lua @ 366:5691edc7dd63

Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
author Matthew Wild <mwild1@gmail.com>
date Fri, 21 Nov 2008 05:02:53 +0000
parent 240:c48dbfa6b1a6
child 519:cccd610a0ef9
comparison
equal deleted inserted replaced
365:a59300fc22ec 366:5691edc7dd63
9 test("node@server", "node", "server", nil ); 9 test("node@server", "node", "server", nil );
10 test("node@server/resource", "node", "server", "resource" ); 10 test("node@server/resource", "node", "server", "resource" );
11 test("server", nil, "server", nil ); 11 test("server", nil, "server", nil );
12 test("server/resource", nil, "server", "resource" ); 12 test("server/resource", nil, "server", "resource" );
13 test(nil, nil, nil , nil ); 13 test(nil, nil, nil , nil );
14
15 test("node@/server", nil, nil, nil , nil );
14 end 16 end
17
18 function bare(bare)
19 assert_equal(bare("user@host"), "user@host", "bare JID remains bare");
20 assert_equal(bare("host"), "host", "Host JID remains host");
21 assert_equal(bare("host/resource"), "host", "Host JID with resource becomes host");
22 assert_equal(bare("user@host/resource"), "user@host", "user@host JID with resource becomes user@host");
23 assert_equal(bare("user@/resource"), nil, "invalid JID is nil");
24 assert_equal(bare("@/resource"), nil, "invalid JID is nil");
25 assert_equal(bare("@/"), nil, "invalid JID is nil");
26 assert_equal(bare("/"), nil, "invalid JID is nil");
27 assert_equal(bare(""), nil, "invalid JID is nil");
28 assert_equal(bare("@"), nil, "invalid JID is nil");
29 assert_equal(bare("user@"), nil, "invalid JID is nil");
30 assert_equal(bare("user@@"), nil, "invalid JID is nil");
31 assert_equal(bare("user@@host"), nil, "invalid JID is nil");
32 assert_equal(bare("user@@host/resource"), nil, "invalid JID is nil");
33 assert_equal(bare("user@host/"), nil, "invalid JID is nil");
34 end