Mercurial > prosody-hg
comparison tests/test_util_jid.lua @ 3451:6402a9defcdc
tests/test_util_jid.lua: Better formatting, comments, and stop giving 5 arguments to a 4-argument function (thanks Asterix :) )
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 10 Aug 2010 14:07:03 +0100 |
| parents | 29e51e1c7c3d |
| children | f68198c2f68f |
comparison
equal
deleted
inserted
replaced
| 3450:4bd78a5fee75 | 3451:6402a9defcdc |
|---|---|
| 23 local rnode, rserver, rresource = split(input_jid); | 23 local rnode, rserver, rresource = split(input_jid); |
| 24 assert_equal(expected_node, rnode, "split("..tostring(input_jid)..") failed"); | 24 assert_equal(expected_node, rnode, "split("..tostring(input_jid)..") failed"); |
| 25 assert_equal(expected_server, rserver, "split("..tostring(input_jid)..") failed"); | 25 assert_equal(expected_server, rserver, "split("..tostring(input_jid)..") failed"); |
| 26 assert_equal(expected_resource, rresource, "split("..tostring(input_jid)..") failed"); | 26 assert_equal(expected_resource, rresource, "split("..tostring(input_jid)..") failed"); |
| 27 end | 27 end |
| 28 | |
| 29 -- Valid JIDs | |
| 28 test("node@server", "node", "server", nil ); | 30 test("node@server", "node", "server", nil ); |
| 29 test("node@server/resource", "node", "server", "resource" ); | 31 test("node@server/resource", "node", "server", "resource" ); |
| 30 test("server", nil, "server", nil ); | 32 test("server", nil, "server", nil ); |
| 31 test("server/resource", nil, "server", "resource" ); | 33 test("server/resource", nil, "server", "resource" ); |
| 32 test(nil, nil, nil , nil ); | |
| 33 | 34 |
| 34 test("node@/server", nil, nil, nil , nil ); | 35 -- Always invalid JIDs |
| 35 test("@server", nil, nil, nil , nil ); | 36 test(nil, nil, nil, nil); |
| 36 test("@server/resource",nil,nil,nil, nil ); | 37 test("node@/server", nil, nil, nil); |
| 38 test("@server", nil, nil, nil); | |
| 39 test("@server/resource", nil, nil, nil); | |
| 37 end | 40 end |
| 38 | 41 |
| 39 function bare(bare) | 42 function bare(bare) |
| 40 assert_equal(bare("user@host"), "user@host", "bare JID remains bare"); | 43 assert_equal(bare("user@host"), "user@host", "bare JID remains bare"); |
| 41 assert_equal(bare("host"), "host", "Host JID remains host"); | 44 assert_equal(bare("host"), "host", "Host JID remains host"); |
