Fri, 16 Jan 2009 04:57:36 +0000
pposix: Add _NAME and _VERSION
615 | 1 | -- Prosody IM v0.2 |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
2 | -- Copyright (C) 2008 Matthew Wild |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
3 | -- Copyright (C) 2008 Waqas Hussain |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
4 | -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
5 | -- This program is free software; you can redistribute it and/or |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
6 | -- modify it under the terms of the GNU General Public License |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
7 | -- as published by the Free Software Foundation; either version 2 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
8 | -- of the License, or (at your option) any later version. |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
9 | -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
10 | -- This program is distributed in the hope that it will be useful, |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
13 | -- GNU General Public License for more details. |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
14 | -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
15 | -- You should have received a copy of the GNU General Public License |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
16 | -- along with this program; if not, write to the Free Software |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
17 | -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
18 | -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
19 | |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
366
diff
changeset
|
20 | |
28
4a238233f278
Adding initial unit testing scripts
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 | |
4a238233f278
Adding initial unit testing scripts
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 | function split(split) |
240
c48dbfa6b1a6
Renamed some of the variables in jid.split test to make it clearer
Matthew Wild <mwild1@gmail.com>
parents:
239
diff
changeset
|
23 | function test(input_jid, expected_node, expected_server, expected_resource) |
c48dbfa6b1a6
Renamed some of the variables in jid.split test to make it clearer
Matthew Wild <mwild1@gmail.com>
parents:
239
diff
changeset
|
24 | local rnode, rserver, rresource = split(input_jid); |
c48dbfa6b1a6
Renamed some of the variables in jid.split test to make it clearer
Matthew Wild <mwild1@gmail.com>
parents:
239
diff
changeset
|
25 | assert_equal(expected_node, rnode, "split("..tostring(input_jid)..") failed"); |
c48dbfa6b1a6
Renamed some of the variables in jid.split test to make it clearer
Matthew Wild <mwild1@gmail.com>
parents:
239
diff
changeset
|
26 | assert_equal(expected_server, rserver, "split("..tostring(input_jid)..") failed"); |
c48dbfa6b1a6
Renamed some of the variables in jid.split test to make it clearer
Matthew Wild <mwild1@gmail.com>
parents:
239
diff
changeset
|
27 | assert_equal(expected_resource, rresource, "split("..tostring(input_jid)..") failed"); |
28
4a238233f278
Adding initial unit testing scripts
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 | end |
4a238233f278
Adding initial unit testing scripts
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 | test("node@server", "node", "server", nil ); |
4a238233f278
Adding initial unit testing scripts
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 | test("node@server/resource", "node", "server", "resource" ); |
4a238233f278
Adding initial unit testing scripts
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 | test("server", nil, "server", nil ); |
4a238233f278
Adding initial unit testing scripts
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 | test("server/resource", nil, "server", "resource" ); |
239 | 33 | test(nil, nil, nil , nil ); |
366
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
34 | |
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
35 | test("node@/server", nil, nil, nil , nil ); |
556
624367a765cd
Add a couple more tests for jid.split
Matthew Wild <mwild1@gmail.com>
parents:
519
diff
changeset
|
36 | test("@server", nil, nil, nil , nil ); |
624367a765cd
Add a couple more tests for jid.split
Matthew Wild <mwild1@gmail.com>
parents:
519
diff
changeset
|
37 | test("@server/resource",nil,nil,nil, nil ); |
28
4a238233f278
Adding initial unit testing scripts
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 | end |
366
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
39 | |
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
40 | function bare(bare) |
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
41 | assert_equal(bare("user@host"), "user@host", "bare JID remains bare"); |
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
42 | assert_equal(bare("host"), "host", "Host JID remains host"); |
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
43 | assert_equal(bare("host/resource"), "host", "Host JID with resource becomes host"); |
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
44 | assert_equal(bare("user@host/resource"), "user@host", "user@host JID with resource becomes user@host"); |
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
45 | assert_equal(bare("user@/resource"), nil, "invalid JID is nil"); |
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
46 | assert_equal(bare("@/resource"), nil, "invalid JID is nil"); |
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
47 | assert_equal(bare("@/"), nil, "invalid JID is nil"); |
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
48 | assert_equal(bare("/"), nil, "invalid JID is nil"); |
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
49 | assert_equal(bare(""), nil, "invalid JID is nil"); |
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
50 | assert_equal(bare("@"), nil, "invalid JID is nil"); |
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
51 | assert_equal(bare("user@"), nil, "invalid JID is nil"); |
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
52 | assert_equal(bare("user@@"), nil, "invalid JID is nil"); |
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
53 | assert_equal(bare("user@@host"), nil, "invalid JID is nil"); |
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
54 | assert_equal(bare("user@@host/resource"), nil, "invalid JID is nil"); |
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
55 | assert_equal(bare("user@host/"), nil, "invalid JID is nil"); |
5691edc7dd63
Improve jid.split() and jid.bare() to pass new test cases with invalid JIDs
Matthew Wild <mwild1@gmail.com>
parents:
240
diff
changeset
|
56 | end |