Add JS files
This commit is contained in:
60570
modules/EcmReports/TableSorterNew/testing/jshint-2.4.4.js
Normal file
60570
modules/EcmReports/TableSorterNew/testing/jshint-2.4.4.js
Normal file
File diff suppressed because it is too large
Load Diff
2288
modules/EcmReports/TableSorterNew/testing/qunit-1.14.0.js
Normal file
2288
modules/EcmReports/TableSorterNew/testing/qunit-1.14.0.js
Normal file
File diff suppressed because it is too large
Load Diff
590
modules/EcmReports/TableSorterNew/testing/testing-ipv6.js
Normal file
590
modules/EcmReports/TableSorterNew/testing/testing-ipv6.js
Normal file
@@ -0,0 +1,590 @@
|
||||
var ipv6parser = $.tablesorter.getParserById('ipv6Address').format,
|
||||
ipv6regex = $.tablesorter.regex.ipv6Validate,
|
||||
ipv6test = function(result, str, expect){
|
||||
if (result) {
|
||||
// ok( $.tablesorter.regex.ipv6Validate.test(str), "valid: " + str );
|
||||
// second parameter = true, so we get the hex format (false or undefined returns decimal)
|
||||
var t = ipv6parser(str, true);
|
||||
equal( t, expect, 'valid: ' + t + ' \u2190 "' + str + '"' );
|
||||
} else {
|
||||
ok( !ipv6regex.test(str), 'invalid: "' + str + '"' );
|
||||
}
|
||||
},
|
||||
ipv6tests = function(){
|
||||
|
||||
test( "ipv6 parser", function() {
|
||||
expect(483);
|
||||
|
||||
// IPV6 tests by Rich Brown copied from http:// download.dartware.com/thirdparty/test-ipv6-regex.pl
|
||||
// modified to compare to canonical ipv6 output using http://www.v6decode.com/ to produce the result
|
||||
ipv6test(!1,""); // empty string
|
||||
ipv6test(1,"::1", "0000:0000:0000:0000:0000:0000:0000:0001"); // loopback, compressed, non-routable
|
||||
ipv6test(1,"::", "0000:0000:0000:0000:0000:0000:0000:0000"); // unspecified, compressed, non-routable
|
||||
ipv6test(1,"0:0:0:0:0:0:0:1", "0000:0000:0000:0000:0000:0000:0000:0001"); // loopback, full
|
||||
ipv6test(1,"0:0:0:0:0:0:0:0", "0000:0000:0000:0000:0000:0000:0000:0000"); // unspecified, full
|
||||
ipv6test(1,"2001:db8:0:0:8:800:200c:417a", "2001:0db8:0000:0000:0008:0800:200c:417a"); // unicast, full
|
||||
ipv6test(1,"ff01:0:0:0:0:0:0:101", "ff01:0000:0000:0000:0000:0000:0000:0101"); // multicast, full
|
||||
ipv6test(1,"2001:db8::8:800:200c:417a", "2001:0db8:0000:0000:0008:0800:200c:417a"); // unicast, compressed
|
||||
ipv6test(1,"ff01::101", "ff01:0000:0000:0000:0000:0000:0000:0101"); // multicast, compressed
|
||||
ipv6test(!1,"2001:db8:0:0:8:800:200c:417a:221"); // unicast, full
|
||||
ipv6test(!1,"ff01::101::2"); // multicast, compressed
|
||||
ipv6test(1,"fe80::217:f2ff:fe07:ed62", "fe80:0000:0000:0000:0217:f2ff:fe07:ed62");
|
||||
|
||||
ipv6test(1,"2001:0000:1234:0000:0000:c1c0:abcd:0876", "2001:0000:1234:0000:0000:c1c0:abcd:0876");
|
||||
ipv6test(1,"3ffe:0b00:0000:0000:0001:0000:0000:000a", "3ffe:0b00:0000:0000:0001:0000:0000:000a");
|
||||
ipv6test(1,"ff02:0000:0000:0000:0000:0000:0000:0001", "ff02:0000:0000:0000:0000:0000:0000:0001");
|
||||
ipv6test(1,"0000:0000:0000:0000:0000:0000:0000:0001", "0000:0000:0000:0000:0000:0000:0000:0001");
|
||||
ipv6test(1,"0000:0000:0000:0000:0000:0000:0000:0000", "0000:0000:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(!1,"02001:0000:1234:0000:0000:c1c0:abcd:0876"); // extra 0 not allowed!
|
||||
ipv6test(!1,"2001:0000:1234:0000:00001:c1c0:abcd:0876"); // extra 0 not allowed!
|
||||
// ipv6test(1," 2001:0000:1234:0000:0000:c1c0:abcd:0876"); // leading space
|
||||
// ipv6test(1,"2001:0000:1234:0000:0000:c1c0:abcd:0876"); // trailing space
|
||||
// ipv6test(1," 2001:0000:1234:0000:0000:c1c0:abcd:0876 "); // leading and trailing space
|
||||
ipv6test(!1,"2001:0000:1234:0000:0000:c1c0:abcd:0876 0"); // junk after valid address
|
||||
ipv6test(!1,"2001:0000:1234: 0000:0000:c1c0:abcd:0876"); // internal space
|
||||
|
||||
ipv6test(!1,"3ffe:0b00:0000:0001:0000:0000:000a"); // seven segments
|
||||
ipv6test(!1,"ff02:0000:0000:0000:0000:0000:0000:0000:0001"); // nine segments
|
||||
ipv6test(!1,"3ffe:b00::1::a"); // double "::"
|
||||
ipv6test(!1,"::1111:2222:3333:4444:5555:6666::"); // double "::"
|
||||
ipv6test(1,"2::10", "0002:0000:0000:0000:0000:0000:0000:0010");
|
||||
ipv6test(1,"ff02::1", "ff02:0000:0000:0000:0000:0000:0000:0001");
|
||||
ipv6test(1,"fe80::", "fe80:0000:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"2002::", "2002:0000:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"2001:db8::", "2001:0db8:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"2001:0db8:1234::", "2001:0db8:1234:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"::ffff:0:0", "0000:0000:0000:0000:0000:ffff:0000:0000");
|
||||
ipv6test(1,"1:2:3:4:5:6:7:8", "0001:0002:0003:0004:0005:0006:0007:0008");
|
||||
ipv6test(1,"1:2:3:4:5:6::8", "0001:0002:0003:0004:0005:0006:0000:0008");
|
||||
ipv6test(1,"1:2:3:4:5::8", "0001:0002:0003:0004:0005:0000:0000:0008");
|
||||
ipv6test(1,"1:2:3:4::8", "0001:0002:0003:0004:0000:0000:0000:0008");
|
||||
ipv6test(1,"1:2:3::8", "0001:0002:0003:0000:0000:0000:0000:0008");
|
||||
ipv6test(1,"1:2::8", "0001:0002:0000:0000:0000:0000:0000:0008");
|
||||
ipv6test(1,"1::8", "0001:0000:0000:0000:0000:0000:0000:0008");
|
||||
ipv6test(1,"1::2:3:4:5:6:7", "0001:0000:0002:0003:0004:0005:0006:0007");
|
||||
ipv6test(1,"1::2:3:4:5:6", "0001:0000:0000:0002:0003:0004:0005:0006");
|
||||
ipv6test(1,"1::2:3:4:5", "0001:0000:0000:0000:0002:0003:0004:0005");
|
||||
ipv6test(1,"1::2:3:4", "0001:0000:0000:0000:0000:0002:0003:0004");
|
||||
ipv6test(1,"1::2:3", "0001:0000:0000:0000:0000:0000:0002:0003");
|
||||
ipv6test(1,"1::8", "0001:0000:0000:0000:0000:0000:0000:0008");
|
||||
ipv6test(1,"::2:3:4:5:6:7:8", "0000:0002:0003:0004:0005:0006:0007:0008");
|
||||
ipv6test(1,"::2:3:4:5:6:7", "0000:0000:0002:0003:0004:0005:0006:0007");
|
||||
ipv6test(1,"::2:3:4:5:6", "0000:0000:0000:0002:0003:0004:0005:0006");
|
||||
ipv6test(1,"::2:3:4:5", "0000:0000:0000:0000:0002:0003:0004:0005");
|
||||
ipv6test(1,"::2:3:4", "0000:0000:0000:0000:0000:0002:0003:0004");
|
||||
ipv6test(1,"::2:3", "0000:0000:0000:0000:0000:0000:0002:0003");
|
||||
ipv6test(1,"::8", "0000:0000:0000:0000:0000:0000:0000:0008");
|
||||
ipv6test(1,"1:2:3:4:5:6::", "0001:0002:0003:0004:0005:0006:0000:0000");
|
||||
ipv6test(1,"1:2:3:4:5::", "0001:0002:0003:0004:0005:0000:0000:0000");
|
||||
ipv6test(1,"1:2:3:4::", "0001:0002:0003:0004:0000:0000:0000:0000");
|
||||
ipv6test(1,"1:2:3::", "0001:0002:0003:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"1:2::", "0001:0002:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"1::", "0001:0000:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"1:2:3:4:5::7:8", "0001:0002:0003:0004:0005:0000:0007:0008");
|
||||
ipv6test(!1,"1:2:3::4:5::7:8"); // double "::"
|
||||
ipv6test(!1,"12345::6:7:8");
|
||||
ipv6test(1,"1:2:3:4::7:8", "0001:0002:0003:0004:0000:0000:0007:0008");
|
||||
ipv6test(1,"1:2:3::7:8", "0001:0002:0003:0000:0000:0000:0007:0008");
|
||||
ipv6test(1,"1:2::7:8", "0001:0002:0000:0000:0000:0000:0007:0008");
|
||||
ipv6test(1,"1::7:8", "0001:0000:0000:0000:0000:0000:0007:0008");
|
||||
|
||||
// ipv4 addresses as dotted-quads
|
||||
ipv6test(1,"1:2:3:4:5:6:1.2.3.4", "0001:0002:0003:0004:0005:0006:0102:0304");
|
||||
ipv6test(1,"1:2:3:4:5::1.2.3.4", "0001:0002:0003:0004:0005:0000:0102:0304");
|
||||
ipv6test(1,"1:2:3:4::1.2.3.4", "0001:0002:0003:0004:0000:0000:0102:0304");
|
||||
ipv6test(1,"1:2:3::1.2.3.4", "0001:0002:0003:0000:0000:0000:0102:0304");
|
||||
ipv6test(1,"1:2::1.2.3.4", "0001:0002:0000:0000:0000:0000:0102:0304");
|
||||
ipv6test(1,"1::1.2.3.4", "0001:0000:0000:0000:0000:0000:0102:0304");
|
||||
ipv6test(1,"1:2:3:4::5:1.2.3.4", "0001:0002:0003:0004:0000:0005:0102:0304");
|
||||
ipv6test(1,"1:2:3::5:1.2.3.4", "0001:0002:0003:0000:0000:0005:0102:0304");
|
||||
ipv6test(1,"1:2::5:1.2.3.4", "0001:0002:0000:0000:0000:0005:0102:0304");
|
||||
ipv6test(1,"1::5:1.2.3.4", "0001:0000:0000:0000:0000:0005:0102:0304");
|
||||
ipv6test(1,"1::5:11.22.33.44", "0001:0000:0000:0000:0000:0005:0b16:212c");
|
||||
ipv6test(!1,"1::5:400.2.3.4");
|
||||
ipv6test(!1,"1::5:260.2.3.4");
|
||||
ipv6test(!1,"1::5:256.2.3.4");
|
||||
ipv6test(!1,"1::5:1.256.3.4");
|
||||
ipv6test(!1,"1::5:1.2.256.4");
|
||||
ipv6test(!1,"1::5:1.2.3.256");
|
||||
ipv6test(!1,"1::5:300.2.3.4");
|
||||
ipv6test(!1,"1::5:1.300.3.4");
|
||||
ipv6test(!1,"1::5:1.2.300.4");
|
||||
ipv6test(!1,"1::5:1.2.3.300");
|
||||
ipv6test(!1,"1::5:900.2.3.4");
|
||||
ipv6test(!1,"1::5:1.900.3.4");
|
||||
ipv6test(!1,"1::5:1.2.900.4");
|
||||
ipv6test(!1,"1::5:1.2.3.900");
|
||||
ipv6test(!1,"1::5:300.300.300.300");
|
||||
ipv6test(!1,"1::5:3000.30.30.30");
|
||||
ipv6test(!1,"1::400.2.3.4");
|
||||
ipv6test(!1,"1::260.2.3.4");
|
||||
ipv6test(!1,"1::256.2.3.4");
|
||||
ipv6test(!1,"1::1.256.3.4");
|
||||
ipv6test(!1,"1::1.2.256.4");
|
||||
ipv6test(!1,"1::1.2.3.256");
|
||||
ipv6test(!1,"1::300.2.3.4");
|
||||
ipv6test(!1,"1::1.300.3.4");
|
||||
ipv6test(!1,"1::1.2.300.4");
|
||||
ipv6test(!1,"1::1.2.3.300");
|
||||
ipv6test(!1,"1::900.2.3.4");
|
||||
ipv6test(!1,"1::1.900.3.4");
|
||||
ipv6test(!1,"1::1.2.900.4");
|
||||
ipv6test(!1,"1::1.2.3.900");
|
||||
ipv6test(!1,"1::300.300.300.300");
|
||||
ipv6test(!1,"1::3000.30.30.30");
|
||||
ipv6test(!1,"::400.2.3.4");
|
||||
ipv6test(!1,"::260.2.3.4");
|
||||
ipv6test(!1,"::256.2.3.4");
|
||||
ipv6test(!1,"::1.256.3.4");
|
||||
ipv6test(!1,"::1.2.256.4");
|
||||
ipv6test(!1,"::1.2.3.256");
|
||||
ipv6test(!1,"::300.2.3.4");
|
||||
ipv6test(!1,"::1.300.3.4");
|
||||
ipv6test(!1,"::1.2.300.4");
|
||||
ipv6test(!1,"::1.2.3.300");
|
||||
ipv6test(!1,"::900.2.3.4");
|
||||
ipv6test(!1,"::1.900.3.4");
|
||||
ipv6test(!1,"::1.2.900.4");
|
||||
ipv6test(!1,"::1.2.3.900");
|
||||
ipv6test(!1,"::300.300.300.300");
|
||||
ipv6test(!1,"::3000.30.30.30");
|
||||
ipv6test(1,"fe80::217:f2ff:254.7.237.98", "fe80:0000:0000:0000:0217:f2ff:fe07:ed62");
|
||||
ipv6test(1,"::ffff:192.168.1.26", "0000:0000:0000:0000:0000:ffff:c0a8:011a");
|
||||
ipv6test(!1,"2001:1:1:1:1:1:255z255x255y255"); // garbage instead of "." in ipv4
|
||||
ipv6test(!1,"::ffff:192x168.1.26"); // ditto
|
||||
ipv6test(1,"::ffff:192.168.1.1", "0000:0000:0000:0000:0000:ffff:c0a8:0101");
|
||||
ipv6test(1,"0:0:0:0:0:0:13.1.68.3", "0000:0000:0000:0000:0000:0000:0d01:4403"); // ipv4-compatible ipv6 address, full, deprecated
|
||||
ipv6test(1,"0:0:0:0:0:ffff:129.144.52.38", "0000:0000:0000:0000:0000:ffff:8190:3426"); // ipv4-mapped ipv6 address, full
|
||||
ipv6test(1,"::13.1.68.3", "0000:0000:0000:0000:0000:0000:0d01:4403"); // ipv4-compatible ipv6 address, compressed, deprecated
|
||||
ipv6test(1,"::ffff:129.144.52.38", "0000:0000:0000:0000:0000:ffff:8190:3426"); // ipv4-mapped ipv6 address, compressed
|
||||
ipv6test(1,"fe80:0:0:0:204:61ff:254.157.241.86", "fe80:0000:0000:0000:0204:61ff:fe9d:f156");
|
||||
ipv6test(1,"fe80::204:61ff:254.157.241.86", "fe80:0000:0000:0000:0204:61ff:fe9d:f156");
|
||||
ipv6test(1,"::ffff:12.34.56.78", "0000:0000:0000:0000:0000:ffff:0c22:384e");
|
||||
ipv6test(!1,"::ffff:2.3.4");
|
||||
ipv6test(!1,"::ffff:257.1.2.3");
|
||||
ipv6test(!1,"1.2.3.4");
|
||||
|
||||
ipv6test(!1,"1.2.3.4:1111:2222:3333:4444::5555"); // aeron
|
||||
ipv6test(!1,"1.2.3.4:1111:2222:3333::5555");
|
||||
ipv6test(!1,"1.2.3.4:1111:2222::5555");
|
||||
ipv6test(!1,"1.2.3.4:1111::5555");
|
||||
ipv6test(!1,"1.2.3.4::5555");
|
||||
ipv6test(!1,"1.2.3.4::");
|
||||
|
||||
// testing ipv4 addresses represented as dotted-quads
|
||||
// leading zero's in ipv4 addresses not allowed: some systems treat the leading "0" in ".086" as the start of an octal number
|
||||
// update: the bnf in rfc-3986 explicitly defines the dec-octet (for ipv4 addresses) not to have a leading zero
|
||||
ipv6test(!1,"fe80:0000:0000:0000:0204:61ff:254.157.241.086");
|
||||
ipv6test(1,"::ffff:192.0.2.128", "0000:0000:0000:0000:0000:ffff:c000:0280"); // but this is ok, since there's a single digit
|
||||
ipv6test(!1,"xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:1.2.3.4");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:00.00.00.00");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:000.000.000.000");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:256.256.256.256");
|
||||
|
||||
// not testing address with subnet mask
|
||||
// ipv6test(1,"2001:0db8:0000:cd30:0000:0000:0000:0000/60"); // full, with prefix
|
||||
// ipv6test(1,"2001:0db8::cd30:0:0:0:0/60"); // compressed, with prefix
|
||||
// ipv6test(1,"2001:0db8:0:cd30::/60"); // compressed, with prefix // 2
|
||||
// ipv6test(1,"::/128"); // compressed, unspecified address type, non-routable
|
||||
// ipv6test(1,"::1/128"); // compressed, loopback address type, non-routable
|
||||
// ipv6test(1,"ff00::/8"); // compressed, multicast address type
|
||||
// ipv6test(1,"fe80::/10"); // compressed, link-local unicast, non-routable
|
||||
// ipv6test(1,"fec0::/10"); // compressed, site-local unicast, deprecated
|
||||
// ipv6test(!1,"124.15.6.89/60"); // standard ipv4, prefix not allowed
|
||||
|
||||
ipv6test(1,"fe80:0000:0000:0000:0204:61ff:fe9d:f156", "fe80:0000:0000:0000:0204:61ff:fe9d:f156");
|
||||
ipv6test(1,"fe80:0:0:0:204:61ff:fe9d:f156", "fe80:0000:0000:0000:0204:61ff:fe9d:f156");
|
||||
ipv6test(1,"fe80::204:61ff:fe9d:f156", "fe80:0000:0000:0000:0204:61ff:fe9d:f156");
|
||||
ipv6test(1,"fe80::", "fe80:0000:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"fe80::1", "fe80:0000:0000:0000:0000:0000:0000:0001");
|
||||
ipv6test(!1,":");
|
||||
ipv6test(1,"::ffff:c000:280", "0000:0000:0000:0000:0000:ffff:c000:0280");
|
||||
|
||||
// aeron supplied these test cases
|
||||
ipv6test(!1,"1111:2222:3333:4444::5555:");
|
||||
ipv6test(!1,"1111:2222:3333::5555:");
|
||||
ipv6test(!1,"1111:2222::5555:");
|
||||
ipv6test(!1,"1111::5555:");
|
||||
ipv6test(!1,"::5555:");
|
||||
ipv6test(!1,":::");
|
||||
ipv6test(!1,"1111:");
|
||||
ipv6test(!1,":");
|
||||
|
||||
ipv6test(!1,":1111:2222:3333:4444::5555");
|
||||
ipv6test(!1,":1111:2222:3333::5555");
|
||||
ipv6test(!1,":1111:2222::5555");
|
||||
ipv6test(!1,":1111::5555");
|
||||
ipv6test(!1,":::5555");
|
||||
ipv6test(!1,":::");
|
||||
|
||||
|
||||
// additional test cases
|
||||
// from http:// rt.cpan.org/public/bug/display.html?id=50693
|
||||
|
||||
ipv6test(1,"2001:0db8:85a3:0000:0000:8a2e:0370:7334", "2001:0db8:85a3:0000:0000:8a2e:0370:7334");
|
||||
ipv6test(1,"2001:db8:85a3:0:0:8a2e:370:7334", "2001:0db8:85a3:0000:0000:8a2e:0370:7334");
|
||||
ipv6test(1,"2001:db8:85a3::8a2e:370:7334", "2001:0db8:85a3:0000:0000:8a2e:0370:7334");
|
||||
ipv6test(1,"2001:0db8:0000:0000:0000:0000:1428:57ab", "2001:0db8:0000:0000:0000:0000:1428:57ab");
|
||||
ipv6test(1,"2001:0db8:0000:0000:0000::1428:57ab", "2001:0db8:0000:0000:0000:0000:1428:57ab");
|
||||
ipv6test(1,"2001:0db8:0:0:0:0:1428:57ab", "2001:0db8:0000:0000:0000:0000:1428:57ab");
|
||||
ipv6test(1,"2001:0db8:0:0::1428:57ab", "2001:0db8:0000:0000:0000:0000:1428:57ab");
|
||||
ipv6test(1,"2001:0db8::1428:57ab", "2001:0db8:0000:0000:0000:0000:1428:57ab");
|
||||
ipv6test(1,"2001:db8::1428:57ab", "2001:0db8:0000:0000:0000:0000:1428:57ab");
|
||||
ipv6test(1,"0000:0000:0000:0000:0000:0000:0000:0001", "0000:0000:0000:0000:0000:0000:0000:0001");
|
||||
ipv6test(1,"::ffff:0c22:384e", "0000:0000:0000:0000:0000:ffff:0c22:384e");
|
||||
ipv6test(1,"2001:0db8:1234:0000:0000:0000:0000:0000", "2001:0db8:1234:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"2001:0db8:1234:ffff:ffff:ffff:ffff:ffff", "2001:0db8:1234:ffff:ffff:ffff:ffff:ffff");
|
||||
ipv6test(1,"2001:db8:a::123", "2001:0db8:000a:0000:0000:0000:0000:0123");
|
||||
ipv6test(1,"fe80::", "fe80:0000:0000:0000:0000:0000:0000:0000");
|
||||
|
||||
ipv6test(!1,"123");
|
||||
ipv6test(!1,"ldkfj");
|
||||
ipv6test(!1,"2001::ffd3::57ab");
|
||||
ipv6test(!1,"2001:db8:85a3::8a2e:37023:7334");
|
||||
ipv6test(!1,"2001:db8:85a3::8a2e:370k:7334");
|
||||
ipv6test(!1,"1:2:3:4:5:6:7:8:9");
|
||||
ipv6test(!1,"1::2::3");
|
||||
ipv6test(!1,"1:::3:4:5");
|
||||
ipv6test(!1,"1:2:3::4:5:6:7:8:9");
|
||||
|
||||
// new from aeron
|
||||
ipv6test(1,"1111:2222:3333:4444:5555:6666:7777:8888", "1111:2222:3333:4444:5555:6666:7777:8888");
|
||||
ipv6test(1,"1111:2222:3333:4444:5555:6666:7777::", "1111:2222:3333:4444:5555:6666:7777:0000");
|
||||
ipv6test(1,"1111:2222:3333:4444:5555:6666::", "1111:2222:3333:4444:5555:6666:0000:0000");
|
||||
ipv6test(1,"1111:2222:3333:4444:5555::", "1111:2222:3333:4444:5555:0000:0000:0000");
|
||||
ipv6test(1,"1111:2222:3333:4444::", "1111:2222:3333:4444:0000:0000:0000:0000");
|
||||
ipv6test(1,"1111:2222:3333::", "1111:2222:3333:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"1111:2222::", "1111:2222:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"1111::", "1111:0000:0000:0000:0000:0000:0000:0000");
|
||||
// ipv6test(1,"::", ""); // duplicate
|
||||
ipv6test(1,"1111:2222:3333:4444:5555:6666::8888", "1111:2222:3333:4444:5555:6666:0000:8888");
|
||||
ipv6test(1,"1111:2222:3333:4444:5555::8888", "1111:2222:3333:4444:5555:0000:0000:8888");
|
||||
ipv6test(1,"1111:2222:3333:4444::8888", "1111:2222:3333:4444:0000:0000:0000:8888");
|
||||
ipv6test(1,"1111:2222:3333::8888", "1111:2222:3333:0000:0000:0000:0000:8888");
|
||||
ipv6test(1,"1111:2222::8888", "1111:2222:0000:0000:0000:0000:0000:8888");
|
||||
ipv6test(1,"1111::8888", "1111:0000:0000:0000:0000:0000:0000:8888");
|
||||
ipv6test(1,"::8888", "0000:0000:0000:0000:0000:0000:0000:8888");
|
||||
ipv6test(1,"1111:2222:3333:4444:5555::7777:8888", "1111:2222:3333:4444:5555:0000:7777:8888");
|
||||
ipv6test(1,"1111:2222:3333:4444::7777:8888", "1111:2222:3333:4444:0000:0000:7777:8888");
|
||||
ipv6test(1,"1111:2222:3333::7777:8888", "1111:2222:3333:0000:0000:0000:7777:8888");
|
||||
ipv6test(1,"1111:2222::7777:8888", "1111:2222:0000:0000:0000:0000:7777:8888");
|
||||
ipv6test(1,"1111::7777:8888", "1111:0000:0000:0000:0000:0000:7777:8888");
|
||||
ipv6test(1,"::7777:8888", "0000:0000:0000:0000:0000:0000:7777:8888");
|
||||
ipv6test(1,"1111:2222:3333:4444::6666:7777:8888", "1111:2222:3333:4444:0000:6666:7777:8888");
|
||||
ipv6test(1,"1111:2222:3333::6666:7777:8888", "1111:2222:3333:0000:0000:6666:7777:8888");
|
||||
ipv6test(1,"1111:2222::6666:7777:8888", "1111:2222:0000:0000:0000:6666:7777:8888");
|
||||
ipv6test(1,"1111::6666:7777:8888", "1111:0000:0000:0000:0000:6666:7777:8888");
|
||||
ipv6test(1,"::6666:7777:8888", "0000:0000:0000:0000:0000:6666:7777:8888");
|
||||
ipv6test(1,"1111:2222:3333::5555:6666:7777:8888", "1111:2222:3333:0000:5555:6666:7777:8888");
|
||||
ipv6test(1,"1111:2222::5555:6666:7777:8888", "1111:2222:0000:0000:5555:6666:7777:8888");
|
||||
ipv6test(1,"1111::5555:6666:7777:8888", "1111:0000:0000:0000:5555:6666:7777:8888");
|
||||
ipv6test(1,"::5555:6666:7777:8888", "0000:0000:0000:0000:5555:6666:7777:8888");
|
||||
ipv6test(1,"1111:2222::4444:5555:6666:7777:8888", "1111:2222:0000:4444:5555:6666:7777:8888");
|
||||
ipv6test(1,"1111::4444:5555:6666:7777:8888", "1111:0000:0000:4444:5555:6666:7777:8888");
|
||||
ipv6test(1,"::4444:5555:6666:7777:8888", "0000:0000:0000:4444:5555:6666:7777:8888");
|
||||
ipv6test(1,"1111::3333:4444:5555:6666:7777:8888", "1111:0000:3333:4444:5555:6666:7777:8888");
|
||||
ipv6test(1,"::3333:4444:5555:6666:7777:8888", "0000:0000:3333:4444:5555:6666:7777:8888");
|
||||
ipv6test(1,"::2222:3333:4444:5555:6666:7777:8888", "0000:2222:3333:4444:5555:6666:7777:8888");
|
||||
ipv6test(1,"1111:2222:3333:4444:5555:6666:123.123.123.123", "1111:2222:3333:4444:5555:6666:7b7b:7b7b");
|
||||
ipv6test(1,"1111:2222:3333:4444:5555::123.123.123.123", "1111:2222:3333:4444:5555:0000:7b7b:7b7b");
|
||||
ipv6test(1,"1111:2222:3333:4444::123.123.123.123", "1111:2222:3333:4444:0000:0000:7b7b:7b7b");
|
||||
ipv6test(1,"1111:2222:3333::123.123.123.123", "1111:2222:3333:0000:0000:0000:7b7b:7b7b");
|
||||
ipv6test(1,"1111:2222::123.123.123.123", "1111:2222:0000:0000:0000:0000:7b7b:7b7b");
|
||||
ipv6test(1,"1111::123.123.123.123", "1111:0000:0000:0000:0000:0000:7b7b:7b7b");
|
||||
ipv6test(1,"::123.123.123.123", "0000:0000:0000:0000:0000:0000:7b7b:7b7b");
|
||||
ipv6test(1,"1111:2222:3333:4444::6666:123.123.123.123", "1111:2222:3333:4444:0000:6666:7b7b:7b7b");
|
||||
ipv6test(1,"1111:2222:3333::6666:123.123.123.123", "1111:2222:3333:0000:0000:6666:7b7b:7b7b");
|
||||
ipv6test(1,"1111:2222::6666:123.123.123.123", "1111:2222:0000:0000:0000:6666:7b7b:7b7b");
|
||||
ipv6test(1,"1111::6666:123.123.123.123", "1111:0000:0000:0000:0000:6666:7b7b:7b7b");
|
||||
ipv6test(1,"::6666:123.123.123.123", "0000:0000:0000:0000:0000:6666:7b7b:7b7b");
|
||||
ipv6test(1,"1111:2222:3333::5555:6666:123.123.123.123", "1111:2222:3333:0000:5555:6666:7b7b:7b7b");
|
||||
ipv6test(1,"1111:2222::5555:6666:123.123.123.123", "1111:2222:0000:0000:5555:6666:7b7b:7b7b");
|
||||
ipv6test(1,"1111::5555:6666:123.123.123.123", "1111:0000:0000:0000:5555:6666:7b7b:7b7b");
|
||||
ipv6test(1,"::5555:6666:123.123.123.123", "0000:0000:0000:0000:5555:6666:7b7b:7b7b");
|
||||
ipv6test(1,"1111:2222::4444:5555:6666:123.123.123.123", "1111:2222:0000:4444:5555:6666:7b7b:7b7b");
|
||||
ipv6test(1,"1111::4444:5555:6666:123.123.123.123", "1111:0000:0000:4444:5555:6666:7b7b:7b7b");
|
||||
ipv6test(1,"::4444:5555:6666:123.123.123.123", "0000:0000:0000:4444:5555:6666:7b7b:7b7b");
|
||||
ipv6test(1,"1111::3333:4444:5555:6666:123.123.123.123", "1111:0000:3333:4444:5555:6666:7b7b:7b7b");
|
||||
ipv6test(1,"::2222:3333:4444:5555:6666:123.123.123.123", "0000:2222:3333:4444:5555:6666:7b7b:7b7b");
|
||||
|
||||
// playing with combinations of "0" and "::"
|
||||
// nb: these are all sytactically correct, but are bad form
|
||||
// because "0" adjacent to "::" should be combined into "::"
|
||||
ipv6test(1,"::0:0:0:0:0:0:0", "0000:0000:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"::0:0:0:0:0:0", "0000:0000:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"::0:0:0:0:0", "0000:0000:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"::0:0:0:0", "0000:0000:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"::0:0:0", "0000:0000:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"::0:0", "0000:0000:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"::0", "0000:0000:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"0:0:0:0:0:0:0::", "0000:0000:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"0:0:0:0:0:0::", "0000:0000:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"0:0:0:0:0::", "0000:0000:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"0:0:0:0::", "0000:0000:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"0:0:0::", "0000:0000:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"0:0::", "0000:0000:0000:0000:0000:0000:0000:0000");
|
||||
ipv6test(1,"0::", "0000:0000:0000:0000:0000:0000:0000:0000");
|
||||
|
||||
// new invalid from aeron
|
||||
// invalid data
|
||||
ipv6test(!1,"xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx");
|
||||
|
||||
// too many components
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:7777:8888:9999");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:7777:8888::");
|
||||
ipv6test(!1,"::2222:3333:4444:5555:6666:7777:8888:9999");
|
||||
|
||||
// too few components
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:7777");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555");
|
||||
ipv6test(!1,"1111:2222:3333:4444");
|
||||
ipv6test(!1,"1111:2222:3333");
|
||||
ipv6test(!1,"1111:2222");
|
||||
ipv6test(!1,"1111");
|
||||
|
||||
// missing :
|
||||
ipv6test(!1,"11112222:3333:4444:5555:6666:7777:8888");
|
||||
ipv6test(!1,"1111:22223333:4444:5555:6666:7777:8888");
|
||||
ipv6test(!1,"1111:2222:33334444:5555:6666:7777:8888");
|
||||
ipv6test(!1,"1111:2222:3333:44445555:6666:7777:8888");
|
||||
ipv6test(!1,"1111:2222:3333:4444:55556666:7777:8888");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:66667777:8888");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:77778888");
|
||||
|
||||
// missing : intended for ::
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:7777:8888:");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:7777:");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:");
|
||||
ipv6test(!1,"1111:2222:3333:4444:");
|
||||
ipv6test(!1,"1111:2222:3333:");
|
||||
ipv6test(!1,"1111:2222:");
|
||||
ipv6test(!1,"1111:");
|
||||
ipv6test(!1,":");
|
||||
ipv6test(!1,":8888");
|
||||
ipv6test(!1,":7777:8888");
|
||||
ipv6test(!1,":6666:7777:8888");
|
||||
ipv6test(!1,":5555:6666:7777:8888");
|
||||
ipv6test(!1,":4444:5555:6666:7777:8888");
|
||||
ipv6test(!1,":3333:4444:5555:6666:7777:8888");
|
||||
ipv6test(!1,":2222:3333:4444:5555:6666:7777:8888");
|
||||
ipv6test(!1,":1111:2222:3333:4444:5555:6666:7777:8888");
|
||||
|
||||
// :::
|
||||
ipv6test(!1,":::2222:3333:4444:5555:6666:7777:8888");
|
||||
ipv6test(!1,"1111:::3333:4444:5555:6666:7777:8888");
|
||||
ipv6test(!1,"1111:2222:::4444:5555:6666:7777:8888");
|
||||
ipv6test(!1,"1111:2222:3333:::5555:6666:7777:8888");
|
||||
ipv6test(!1,"1111:2222:3333:4444:::6666:7777:8888");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:::7777:8888");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:::8888");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:7777:::");
|
||||
|
||||
// double ::");
|
||||
ipv6test(!1,"::2222::4444:5555:6666:7777:8888");
|
||||
ipv6test(!1,"::2222:3333::5555:6666:7777:8888");
|
||||
ipv6test(!1,"::2222:3333:4444::6666:7777:8888");
|
||||
ipv6test(!1,"::2222:3333:4444:5555::7777:8888");
|
||||
ipv6test(!1,"::2222:3333:4444:5555:7777::8888");
|
||||
ipv6test(!1,"::2222:3333:4444:5555:7777:8888::");
|
||||
|
||||
ipv6test(!1,"1111::3333::5555:6666:7777:8888");
|
||||
ipv6test(!1,"1111::3333:4444::6666:7777:8888");
|
||||
ipv6test(!1,"1111::3333:4444:5555::7777:8888");
|
||||
ipv6test(!1,"1111::3333:4444:5555:6666::8888");
|
||||
ipv6test(!1,"1111::3333:4444:5555:6666:7777::");
|
||||
|
||||
ipv6test(!1,"1111:2222::4444::6666:7777:8888");
|
||||
ipv6test(!1,"1111:2222::4444:5555::7777:8888");
|
||||
ipv6test(!1,"1111:2222::4444:5555:6666::8888");
|
||||
ipv6test(!1,"1111:2222::4444:5555:6666:7777::");
|
||||
|
||||
ipv6test(!1,"1111:2222:3333::5555::7777:8888");
|
||||
ipv6test(!1,"1111:2222:3333::5555:6666::8888");
|
||||
ipv6test(!1,"1111:2222:3333::5555:6666:7777::");
|
||||
|
||||
ipv6test(!1,"1111:2222:3333:4444::6666::8888");
|
||||
ipv6test(!1,"1111:2222:3333:4444::6666:7777::");
|
||||
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555::7777::");
|
||||
|
||||
|
||||
// too many components"
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:7777:8888:1.2.3.4");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:7777:1.2.3.4");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666::1.2.3.4");
|
||||
ipv6test(!1,"::2222:3333:4444:5555:6666:7777:1.2.3.4");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:1.2.3.4.5");
|
||||
|
||||
// too few components
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:1.2.3.4");
|
||||
ipv6test(!1,"1111:2222:3333:4444:1.2.3.4");
|
||||
ipv6test(!1,"1111:2222:3333:1.2.3.4");
|
||||
ipv6test(!1,"1111:2222:1.2.3.4");
|
||||
ipv6test(!1,"1111:1.2.3.4");
|
||||
ipv6test(!1,"1.2.3.4");
|
||||
|
||||
// missing :
|
||||
ipv6test(!1,"11112222:3333:4444:5555:6666:1.2.3.4");
|
||||
ipv6test(!1,"1111:22223333:4444:5555:6666:1.2.3.4");
|
||||
ipv6test(!1,"1111:2222:33334444:5555:6666:1.2.3.4");
|
||||
ipv6test(!1,"1111:2222:3333:44445555:6666:1.2.3.4");
|
||||
ipv6test(!1,"1111:2222:3333:4444:55556666:1.2.3.4");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:66661.2.3.4");
|
||||
|
||||
// missing .
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:255255.255.255");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:255.255255.255");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:255.255.255255");
|
||||
|
||||
// missing : intended for ::
|
||||
ipv6test(!1,":1.2.3.4");
|
||||
ipv6test(!1,":6666:1.2.3.4");
|
||||
ipv6test(!1,":5555:6666:1.2.3.4");
|
||||
ipv6test(!1,":4444:5555:6666:1.2.3.4");
|
||||
ipv6test(!1,":3333:4444:5555:6666:1.2.3.4");
|
||||
ipv6test(!1,":2222:3333:4444:5555:6666:1.2.3.4");
|
||||
ipv6test(!1,":1111:2222:3333:4444:5555:6666:1.2.3.4");
|
||||
|
||||
// :::
|
||||
ipv6test(!1,":::2222:3333:4444:5555:6666:1.2.3.4");
|
||||
ipv6test(!1,"1111:::3333:4444:5555:6666:1.2.3.4");
|
||||
ipv6test(!1,"1111:2222:::4444:5555:6666:1.2.3.4");
|
||||
ipv6test(!1,"1111:2222:3333:::5555:6666:1.2.3.4");
|
||||
ipv6test(!1,"1111:2222:3333:4444:::6666:1.2.3.4");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:::1.2.3.4");
|
||||
|
||||
// double ::
|
||||
ipv6test(!1,"::2222::4444:5555:6666:1.2.3.4");
|
||||
ipv6test(!1,"::2222:3333::5555:6666:1.2.3.4");
|
||||
ipv6test(!1,"::2222:3333:4444::6666:1.2.3.4");
|
||||
ipv6test(!1,"::2222:3333:4444:5555::1.2.3.4");
|
||||
|
||||
ipv6test(!1,"1111::3333::5555:6666:1.2.3.4");
|
||||
ipv6test(!1,"1111::3333:4444::6666:1.2.3.4");
|
||||
ipv6test(!1,"1111::3333:4444:5555::1.2.3.4");
|
||||
|
||||
ipv6test(!1,"1111:2222::4444::6666:1.2.3.4");
|
||||
ipv6test(!1,"1111:2222::4444:5555::1.2.3.4");
|
||||
|
||||
ipv6test(!1,"1111:2222:3333::5555::1.2.3.4");
|
||||
|
||||
// missing parts
|
||||
ipv6test(!1,"::.");
|
||||
ipv6test(!1,"::..");
|
||||
ipv6test(!1,"::...");
|
||||
ipv6test(!1,"::1...");
|
||||
ipv6test(!1,"::1.2..");
|
||||
ipv6test(!1,"::1.2.3.");
|
||||
ipv6test(!1,"::.2..");
|
||||
ipv6test(!1,"::.2.3.");
|
||||
ipv6test(!1,"::.2.3.4");
|
||||
ipv6test(!1,"::..3.");
|
||||
ipv6test(!1,"::..3.4");
|
||||
ipv6test(!1,"::...4");
|
||||
|
||||
// extra : in front
|
||||
ipv6test(!1,":1111:2222:3333:4444:5555:6666:7777::");
|
||||
ipv6test(!1,":1111:2222:3333:4444:5555:6666::");
|
||||
ipv6test(!1,":1111:2222:3333:4444:5555::");
|
||||
ipv6test(!1,":1111:2222:3333:4444::");
|
||||
ipv6test(!1,":1111:2222:3333::");
|
||||
ipv6test(!1,":1111:2222::");
|
||||
ipv6test(!1,":1111::");
|
||||
ipv6test(!1,":::");
|
||||
ipv6test(!1,":1111:2222:3333:4444:5555:6666::8888");
|
||||
ipv6test(!1,":1111:2222:3333:4444:5555::8888");
|
||||
ipv6test(!1,":1111:2222:3333:4444::8888");
|
||||
ipv6test(!1,":1111:2222:3333::8888");
|
||||
ipv6test(!1,":1111:2222::8888");
|
||||
ipv6test(!1,":1111::8888");
|
||||
ipv6test(!1,":::8888");
|
||||
ipv6test(!1,":1111:2222:3333:4444:5555::7777:8888");
|
||||
ipv6test(!1,":1111:2222:3333:4444::7777:8888");
|
||||
ipv6test(!1,":1111:2222:3333::7777:8888");
|
||||
ipv6test(!1,":1111:2222::7777:8888");
|
||||
ipv6test(!1,":1111::7777:8888");
|
||||
ipv6test(!1,":::7777:8888");
|
||||
ipv6test(!1,":1111:2222:3333:4444::6666:7777:8888");
|
||||
ipv6test(!1,":1111:2222:3333::6666:7777:8888");
|
||||
ipv6test(!1,":1111:2222::6666:7777:8888");
|
||||
ipv6test(!1,":1111::6666:7777:8888");
|
||||
ipv6test(!1,":::6666:7777:8888");
|
||||
ipv6test(!1,":1111:2222:3333::5555:6666:7777:8888");
|
||||
ipv6test(!1,":1111:2222::5555:6666:7777:8888");
|
||||
ipv6test(!1,":1111::5555:6666:7777:8888");
|
||||
ipv6test(!1,":::5555:6666:7777:8888");
|
||||
ipv6test(!1,":1111:2222::4444:5555:6666:7777:8888");
|
||||
ipv6test(!1,":1111::4444:5555:6666:7777:8888");
|
||||
ipv6test(!1,":::4444:5555:6666:7777:8888");
|
||||
ipv6test(!1,":1111::3333:4444:5555:6666:7777:8888");
|
||||
ipv6test(!1,":::3333:4444:5555:6666:7777:8888");
|
||||
ipv6test(!1,":::2222:3333:4444:5555:6666:7777:8888");
|
||||
ipv6test(!1,":1111:2222:3333:4444:5555:6666:1.2.3.4");
|
||||
ipv6test(!1,":1111:2222:3333:4444:5555::1.2.3.4");
|
||||
ipv6test(!1,":1111:2222:3333:4444::1.2.3.4");
|
||||
ipv6test(!1,":1111:2222:3333::1.2.3.4");
|
||||
ipv6test(!1,":1111:2222::1.2.3.4");
|
||||
ipv6test(!1,":1111::1.2.3.4");
|
||||
ipv6test(!1,":::1.2.3.4");
|
||||
ipv6test(!1,":1111:2222:3333:4444::6666:1.2.3.4");
|
||||
ipv6test(!1,":1111:2222:3333::6666:1.2.3.4");
|
||||
ipv6test(!1,":1111:2222::6666:1.2.3.4");
|
||||
ipv6test(!1,":1111::6666:1.2.3.4");
|
||||
ipv6test(!1,":::6666:1.2.3.4");
|
||||
ipv6test(!1,":1111:2222:3333::5555:6666:1.2.3.4");
|
||||
ipv6test(!1,":1111:2222::5555:6666:1.2.3.4");
|
||||
ipv6test(!1,":1111::5555:6666:1.2.3.4");
|
||||
ipv6test(!1,":::5555:6666:1.2.3.4");
|
||||
ipv6test(!1,":1111:2222::4444:5555:6666:1.2.3.4");
|
||||
ipv6test(!1,":1111::4444:5555:6666:1.2.3.4");
|
||||
ipv6test(!1,":::4444:5555:6666:1.2.3.4");
|
||||
ipv6test(!1,":1111::3333:4444:5555:6666:1.2.3.4");
|
||||
ipv6test(!1,":::2222:3333:4444:5555:6666:1.2.3.4");
|
||||
|
||||
// extra : at end
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:7777:::");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666:::");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:::");
|
||||
ipv6test(!1,"1111:2222:3333:4444:::");
|
||||
ipv6test(!1,"1111:2222:3333:::");
|
||||
ipv6test(!1,"1111:2222:::");
|
||||
ipv6test(!1,"1111:::");
|
||||
ipv6test(!1,":::");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555:6666::8888:");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555::8888:");
|
||||
ipv6test(!1,"1111:2222:3333:4444::8888:");
|
||||
ipv6test(!1,"1111:2222:3333::8888:");
|
||||
ipv6test(!1,"1111:2222::8888:");
|
||||
ipv6test(!1,"1111::8888:");
|
||||
ipv6test(!1,"::8888:");
|
||||
ipv6test(!1,"1111:2222:3333:4444:5555::7777:8888:");
|
||||
ipv6test(!1,"1111:2222:3333:4444::7777:8888:");
|
||||
ipv6test(!1,"1111:2222:3333::7777:8888:");
|
||||
ipv6test(!1,"1111:2222::7777:8888:");
|
||||
ipv6test(!1,"1111::7777:8888:");
|
||||
ipv6test(!1,"::7777:8888:");
|
||||
ipv6test(!1,"1111:2222:3333:4444::6666:7777:8888:");
|
||||
ipv6test(!1,"1111:2222:3333::6666:7777:8888:");
|
||||
ipv6test(!1,"1111:2222::6666:7777:8888:");
|
||||
ipv6test(!1,"1111::6666:7777:8888:");
|
||||
ipv6test(!1,"::6666:7777:8888:");
|
||||
ipv6test(!1,"1111:2222:3333::5555:6666:7777:8888:");
|
||||
ipv6test(!1,"1111:2222::5555:6666:7777:8888:");
|
||||
ipv6test(!1,"1111::5555:6666:7777:8888:");
|
||||
ipv6test(!1,"::5555:6666:7777:8888:");
|
||||
ipv6test(!1,"1111:2222::4444:5555:6666:7777:8888:");
|
||||
ipv6test(!1,"1111::4444:5555:6666:7777:8888:");
|
||||
ipv6test(!1,"::4444:5555:6666:7777:8888:");
|
||||
ipv6test(!1,"1111::3333:4444:5555:6666:7777:8888:");
|
||||
ipv6test(!1,"::3333:4444:5555:6666:7777:8888:");
|
||||
ipv6test(!1,"::2222:3333:4444:5555:6666:7777:8888:");
|
||||
|
||||
// additional cases: http:// crisp.tweakblogs.net/blog/2031/ipv6-validation-%28and-caveats%29.html
|
||||
ipv6test(1,"0:a:b:c:d:e:f::", "0000:000a:000b:000c:000d:000e:000f:0000");
|
||||
ipv6test(1,"::0:a:b:c:d:e:f", "0000:0000:000a:000b:000c:000d:000e:000f"); // syntactically correct, but bad form (::0:... could be combined)
|
||||
ipv6test(1,"a:b:c:d:e:f:0::", "000a:000b:000c:000d:000e:000f:0000:0000");
|
||||
ipv6test(!1,"':10.0.0.1");
|
||||
});
|
||||
};
|
||||
369
modules/EcmReports/TableSorterNew/testing/testing-widgets.js
Normal file
369
modules/EcmReports/TableSorterNew/testing/testing-widgets.js
Normal file
@@ -0,0 +1,369 @@
|
||||
/*!
|
||||
* TableSorter QUnit Testing
|
||||
*/
|
||||
/*jshint unused: false */
|
||||
/*global start: false, asyncTest: false, equal: false, $: false, expect: false, module: false,
|
||||
tester: false, test: false, stop: false */
|
||||
|
||||
/*
|
||||
Filter widget tested parts
|
||||
========================
|
||||
OPTIONS:
|
||||
filter_defaultAttrib, filter_ignoreCase, filter_startsWith,
|
||||
filter_selectSource, filter_functions (set, not functionality)
|
||||
|
||||
CLASSES:
|
||||
filter-false, filter-match, filter-parsed
|
||||
|
||||
METHODS:
|
||||
filterReset, search (false), setFilters
|
||||
|
||||
EVENTS:
|
||||
filterInit, filterEnd
|
||||
|
||||
Not yet tested
|
||||
=========================
|
||||
OPTIONS:
|
||||
filter_childRows, filter_columnFilters, filter_cssFilter, filter_external,
|
||||
filter_filteredRow, filter_formatter, filter_hideEmpty,
|
||||
filter_hideEmpty, filter_liveSearch, filter_onlyAvail, filter_placeholder,
|
||||
filter_reset, filter_saveFilters, filter_searchDelay,
|
||||
filter_serversideFiltering, filter_useParsedData
|
||||
|
||||
CLASSES:
|
||||
filter-select, filter-select-nosort, filter-onlyAvail
|
||||
|
||||
METHODS:
|
||||
search (array), getFilters, external filters
|
||||
|
||||
EVENTS:
|
||||
filterStart
|
||||
*/
|
||||
|
||||
$(function(){
|
||||
module('Widgets');
|
||||
|
||||
var ts = $.tablesorter,
|
||||
callback = {},
|
||||
callbackName = 'init',
|
||||
|
||||
// filter widget table
|
||||
$table = $('#testblock').html('<table class="tablesorter">' +
|
||||
'<thead><tr>' +
|
||||
'<th class="rank">Rank</th>' +
|
||||
'<th class="first filter-match">First Name</th>' +
|
||||
'<th class="last">Last Name</th>' +
|
||||
'<th data-value="<20">Age</th>' +
|
||||
'<th class="total">Total</th>' +
|
||||
'<th>Discount</th>' +
|
||||
'<th>Date</th>' +
|
||||
'<th class="last2">Last Name2</th>' +
|
||||
'</tr></thead><tbody>' +
|
||||
'<tr><td>1</td><td>Philip Aaron Wong</td><td>Johnson Sr Esq</td><td>25</td><td>$5.95</td><td>22%</td><td>Jun 26, 2004 7:22 AM</td><td>Johnson Sr Esq</td></tr>' +
|
||||
'<tr><td>11</td><td>Aaron</td><td>Hibert</td><td>12</td><td>$2.99</td><td>5%</td><td>Aug 21, 2009 12:21 PM</td><td>Hibert</td></tr>' +
|
||||
'<tr><td>12</td><td>Brandon Clark</td><td>Henry Jr</td><td>51</td><td>$42.29</td><td>18%</td><td>Oct 13, 2000 1:15 PM</td><td>Henry Jr</td></tr>' +
|
||||
'<tr><td>111</td><td>Peter</td><td>Parker</td><td>28</td><td>$9.99</td><td>20%</td><td>Jul 6, 2006 8:14 AM</td><td>Parker</td></tr>' +
|
||||
'<tr><td>21</td><td>John</td><td>Hood</td><td>33</td><td>$19.99</td><td>25%</td><td>Dec 10, 2002 5:14 AM</td><td>Hood</td></tr>' +
|
||||
'<tr><td>013</td><td>Clark</td><td>Kent Sr.</td><td>18</td><td>$15.89</td><td>44%</td><td>Jan 12, 2003 11:14 AM</td><td>Kent Sr.</td></tr>' +
|
||||
'<tr><td>005</td><td>Bruce</td><td>Almighty Esq</td><td>45</td><td>$153.19</td><td>44%</td><td>Jan 18, 2021 9:12 AM</td><td>Almighty Esq</td></tr>' +
|
||||
'<tr><td>10</td><td>Alex</td><td>Dumass</td><td>13</td><td>$5.29</td><td>4%</td><td>Jan 8, 2012 5:11 PM</td><td>Dumass</td></tr>' +
|
||||
'<tr><td>16</td><td>Jim</td><td>Franco</td><td>24</td><td>$14.19</td><td>14%</td><td>Jan 14, 2004 11:23 AM</td><td>Franco</td></tr>' +
|
||||
'<tr><td>166</td><td>Bruce Lee</td><td>Evans</td><td>22</td><td>$13.19</td><td>11%</td><td>Jan 18, 2007 9:12 AM</td><td>Evans</td></tr>' +
|
||||
'<tr><td>100</td><td>Brenda Dexter</td><td>McMasters</td><td>18</td><td>$55.20</td><td>15%</td><td>Feb 12, 2010 7:23 PM</td><td>McMasters</td></tr>' +
|
||||
'<tr><td>55</td><td>Dennis</td><td>Bronson</td><td>65</td><td>$123.00</td><td>32%</td><td>Jan 20, 2001 1:12 PM</td><td>Bronson</td></tr>' +
|
||||
'<tr><td>9</td><td>Martha</td><td>delFuego</td><td>25</td><td>$22.09</td><td>17%</td><td>Jun 11, 2011 10:55 AM</td><td>delFuego</td></tr>' +
|
||||
'</tbody></table>').find('table'),
|
||||
table = $table[0],
|
||||
|
||||
/************************************************
|
||||
Filter widget
|
||||
************************************************/
|
||||
init = false,
|
||||
|
||||
runFilterTests = function(){
|
||||
|
||||
var c = table.config,
|
||||
wo = c.widgetOptions;
|
||||
|
||||
test( 'Filter: init', function() {
|
||||
expect(6);
|
||||
|
||||
equal( init, true, 'Init event' );
|
||||
equal( $table.hasClass('hasFilters'), true, '`hasFilters` class applied' );
|
||||
|
||||
equal( ts.filter.regex.child.test( c.cssChildRow ), true, 'child row regex check' );
|
||||
equal( ts.filter.regex.filtered.test( wo.filter_filteredRow ), true, 'filtered row regex check' );
|
||||
// this includes check of headers option & referencing column by class
|
||||
equal ( c.$table.find('.tablesorter-filter').eq(0).hasClass('disabled'), true, 'filter disabled & headers class name working' );
|
||||
|
||||
tester.cacheCompare( table, 3, [ 12, 18, 13, 18 ], 'starting filter value on age column', true );
|
||||
});
|
||||
|
||||
asyncTest( 'Filter searches', function() {
|
||||
expect(27);
|
||||
|
||||
callbackName = 'regular';
|
||||
callback.regular = function(){
|
||||
tester.cacheCompare( table, 1, ['Peter', 'Bruce', 'Alex', 'Bruce Lee', 'Brenda Dexter', 'Dennis'], 'search regular', true );
|
||||
};
|
||||
ts.setFilters( table, ['', 'e'], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'fuzzy1';
|
||||
callback.fuzzy1 = function(){
|
||||
tester.cacheCompare( table, 1, ['Bruce Lee', 'Brenda Dexter'], 'search fuzzy', true );
|
||||
};
|
||||
ts.setFilters( table, ['', '~bee'], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'fuzzy2';
|
||||
callback.fuzzy2 = function(){
|
||||
tester.cacheCompare( table, 1, ['Philip Aaron Wong'], 'search fuzzy2', true );
|
||||
};
|
||||
ts.setFilters( table, ['', '~piano'], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'exact';
|
||||
callback.exact = function(){
|
||||
tester.cacheCompare( table, 1, ['John'], 'search exact', true );
|
||||
};
|
||||
ts.setFilters( table, ['', 'john='], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'wildcard1';
|
||||
callback.wildcard1 = function(){
|
||||
tester.cacheCompare( table, 2, ['Dumass', 'Evans'], 'search wildcard, one character (?)', true );
|
||||
};
|
||||
ts.setFilters( table, ['', '', 'a?s'], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'wildcard2';
|
||||
callback.wildcard2 = function(){
|
||||
tester.cacheCompare( table, 2, ['Dumass', 'Evans', 'McMasters'], 'search wildcard, multiple characters (*)', true );
|
||||
};
|
||||
ts.setFilters( table, ['', '', 'a*s'], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'regex';
|
||||
callback.regex = function(){
|
||||
tester.cacheCompare( table, 1, ['Peter', 'Brenda Dexter'], 'search regex', true );
|
||||
};
|
||||
ts.setFilters( table, ['', '/r$/'], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'operator';
|
||||
callback.operator = function(){
|
||||
tester.cacheCompare( table, 4, [42.29, 19.99, 15.89, 153.19, 14.19, 13.19, 55.2, 123, 22.09], 'search operator (>10)', true );
|
||||
};
|
||||
ts.setFilters( table, ['', '', '', '', '>10'], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'operator1';
|
||||
callback.operator1 = function(){
|
||||
tester.cacheCompare( table, 4, [153.19, 123], 'search operator (>100); ensure search filtered gets cleared', true );
|
||||
};
|
||||
ts.setFilters( table, ['', '', '', '', '>100'], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'operator2';
|
||||
callback.operator2 = function(){
|
||||
tester.cacheCompare( table, 5, [22, 20, 25, 44, 44, 32], 'search operator (>=)', true );
|
||||
};
|
||||
ts.setFilters( table, ['', '', '', '', '', '>=20'], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'operator3';
|
||||
callback.operator3 = function(){
|
||||
tester.cacheCompare( table, 5, [5, 4], 'search operator (<10)', true );
|
||||
};
|
||||
ts.setFilters( table, ['', '', '', '', '', '<10'], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'operator4';
|
||||
callback.operator4 = function(){
|
||||
tester.cacheCompare( table, 5, [22, 5, 18, 20, 25, 44, 44, 4, 14, 11, 15, 32, 17], 'search operator (<100); ensure search filtered gets cleared', true );
|
||||
};
|
||||
ts.setFilters( table, ['', '', '', '', '', '<100'], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'operator5';
|
||||
callback.operator5 = function(){
|
||||
tester.cacheCompare( table, 5, [5, 18, 20, 4, 14, 11, 15, 17], 'search operator (<=)', true );
|
||||
};
|
||||
ts.setFilters( table, ['', '', '', '', '', '<=20'], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'notMatch';
|
||||
callback.notMatch = function(){
|
||||
tester.cacheCompare( table, 1, ['Peter', 'John', 'Bruce', 'Jim', 'Bruce Lee', 'Dennis'], 'search not match', true );
|
||||
};
|
||||
ts.setFilters( table, ['', '!a'], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'notMatch2';
|
||||
callback.notMatch2 = function(){
|
||||
tester.cacheCompare( table, 1, ['Brandon Clark', 'Peter', 'John', 'Clark', 'Bruce', 'Alex', 'Jim', 'Bruce Lee', 'Brenda Dexter', 'Dennis', 'Martha'], 'search not match; ensure search filtered gets cleared', true );
|
||||
};
|
||||
ts.setFilters( table, ['', '!aa'], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'operatorAnd';
|
||||
callback.operatorAnd = function(){
|
||||
tester.cacheCompare( table, 1, ['Brandon Clark', 'Bruce', 'Bruce Lee'], 'search and match', true );
|
||||
};
|
||||
ts.setFilters( table, ['', 'br && c'], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'operatorAnd2';
|
||||
callback.operatorAnd2 = function(){
|
||||
tester.cacheCompare( table, 1, ['Brandon Clark'], 'search and match; ensure search filtered gets cleared', true );
|
||||
};
|
||||
ts.setFilters( table, ['', 'br && cl'], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'operatorOr';
|
||||
callback.operatorOr = function(){
|
||||
tester.cacheCompare( table, 1, ['Brandon Clark', 'Bruce', 'Alex', 'Bruce Lee', 'Brenda Dexter'], 'search OR match', true );
|
||||
};
|
||||
ts.setFilters( table, ['', 'alex|br*'], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'range';
|
||||
callback.range = function(){
|
||||
tester.cacheCompare( table, 4, [5.95, 9.99, 5.29], 'search range', true );
|
||||
};
|
||||
ts.setFilters( table, ['', '', '', '', '5 - 10'], true );
|
||||
stop();
|
||||
|
||||
callbackName = 'range2';
|
||||
callback.range2 = function(){
|
||||
tester.cacheCompare( table, 4, [5.95, 42.29, 9.99, 19.99, 15.89, 5.29, 14.19, 13.19, 55.2, 22.09], 'search range; ensure search filtered gets cleared', true );
|
||||
};
|
||||
ts.setFilters( table, ['', '', '', '', '5 - 100'], true );
|
||||
stop();
|
||||
|
||||
// test filter_startsWith (false by default)
|
||||
wo.filter_startsWith = false;
|
||||
callbackName = 'startsWith';
|
||||
callback.startsWith = function(){
|
||||
tester.cacheCompare( table, 1, ['Philip Aaron Wong', 'Aaron'], 'search - filter_startsWith : false', true );
|
||||
};
|
||||
ts.setFilters( table, ['', 'aa'], true );
|
||||
stop();
|
||||
|
||||
// test filter_startsWith (false by default)
|
||||
wo.filter_startsWith = true;
|
||||
callbackName = 'startsWith2';
|
||||
callback.startsWith2 = function(){
|
||||
tester.cacheCompare( table, 1, ['Aaron'], 'search - filter_startsWith : true', true );
|
||||
wo.filter_startsWith = false;
|
||||
};
|
||||
c.$table.trigger('search', false);
|
||||
stop();
|
||||
|
||||
// test filter_ignoreCase (true by default)
|
||||
wo.filter_ignoreCase = false;
|
||||
callbackName = 'ignoreCase1';
|
||||
callback.ignoreCase1 = function(){
|
||||
tester.cacheCompare( table, 1, [], 'search - filter_ignoreCase : false', true );
|
||||
wo.filter_ignoreCase = true;
|
||||
};
|
||||
c.$table.trigger('search', false);
|
||||
stop();
|
||||
|
||||
// test filter-match class (added in the example code)
|
||||
callbackName = 'filterMatch';
|
||||
callback.filterMatch = function(){
|
||||
tester.cacheCompare( table, 1, ['Brandon Clark', 'Clark', 'Bruce', 'Alex', 'Bruce Lee', 'Brenda Dexter'], 'search - filter-match', true );
|
||||
};
|
||||
ts.setFilters( table, ['', 'alex|br*|c'], true );
|
||||
stop();
|
||||
|
||||
// test filter-match class
|
||||
c.$table.find('.tablesorter-header').eq(1).removeClass('filter-match');
|
||||
callbackName = 'notFilterMatch';
|
||||
callback.notFilterMatch = function(){
|
||||
tester.cacheCompare( table, 1, ['Bruce', 'Alex'], 'search - filter-match removed', true );
|
||||
};
|
||||
c.$table.trigger('search', false);
|
||||
stop();
|
||||
|
||||
// filter reset
|
||||
callbackName = 'filterReset';
|
||||
callback.filterReset = function(){
|
||||
tester.cacheCompare( table, 5, [22, 5, 18, 20, 25, 44, 44, 4, 14, 11, 15, 32, 17], 'filterReset', true );
|
||||
};
|
||||
c.$table.trigger('filterReset');
|
||||
stop();
|
||||
|
||||
// filter parsed class
|
||||
wo.filter_startsWith = false;
|
||||
callbackName = 'filterParsed';
|
||||
callback.filterParsed = function(){
|
||||
tester.cacheCompare( table, 6, [ new Date('Oct 13, 2000 1:15 PM').getTime() ], 'search - filter-parsed', true );
|
||||
};
|
||||
ts.setFilters( table, ['', '', '', '', '', '', '< 1/1/2001'], true );
|
||||
|
||||
});
|
||||
|
||||
test( 'Filter: function & selectSource', function() {
|
||||
expect(3);
|
||||
|
||||
var $t, opts = [];
|
||||
$t = c.$table.find('.tablesorter-filter-row select:last');
|
||||
equal ( $t.length !== 0, true, 'filter_functions: true working' );
|
||||
|
||||
c.$table.find('.tablesorter-filter-row select:first option').each(function(){
|
||||
opts.push( $.trim( $(this).text() ) );
|
||||
});
|
||||
equal ( opts.length === 3 && opts.join('') === '< 10> 10', true, 'filter_functions set' );
|
||||
|
||||
opts = [];
|
||||
$t.find('option').each(function(){
|
||||
opts.push( $.trim( $(this).text() ) );
|
||||
});
|
||||
equal ( opts.length === 4 && opts.join('') === 'abcdefzyx', true, 'filter_selectSource set' );
|
||||
|
||||
});
|
||||
|
||||
|
||||
$table.on('filterEnd', function(){
|
||||
start();
|
||||
if (callbackName !== '' && callback[callbackName]) {
|
||||
callback[callbackName]();
|
||||
}
|
||||
callbackName = '';
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
$table
|
||||
.on('filterInit', function(){
|
||||
init = true;
|
||||
runFilterTests();
|
||||
})
|
||||
.tablesorter({
|
||||
ignoreCase: false,
|
||||
widgets: ['zebra', 'filter'],
|
||||
headers: {
|
||||
'.rank' : { filter: false }
|
||||
},
|
||||
widgetOptions: {
|
||||
filter_functions : {
|
||||
'.last2' : true,
|
||||
'.rank' : {
|
||||
"< 10" : function(e, n) { return n <= 10; },
|
||||
"> 10" : function(e, n) { return n > 10; }
|
||||
}
|
||||
},
|
||||
filter_selectSource : {
|
||||
// Alphanumeric match (prefix only)
|
||||
// added as select2 options (you could also use select2 data option)
|
||||
'.last2' : function(table, column) {
|
||||
return ['abc', 'def', 'zyx'];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
765
modules/EcmReports/TableSorterNew/testing/testing.js
Normal file
765
modules/EcmReports/TableSorterNew/testing/testing.js
Normal file
@@ -0,0 +1,765 @@
|
||||
/*!
|
||||
* TableSorter QUnit Testing
|
||||
*/
|
||||
/*jshint unused: false */
|
||||
/*global QUnit: false, JSHINT: false, ok: false, start: false, deepEqual: false, asyncTest: false,
|
||||
strictEqual: false, jQuery: false, equal: false, $: false, expect: false, module: false,
|
||||
test: false, stop: false, ipv6tests: false */
|
||||
|
||||
/************************************************
|
||||
QUnit skip testing
|
||||
http://stackoverflow.com/q/13748129/145346
|
||||
************************************************/
|
||||
QUnit.testSkip = function( testName, callback ) {
|
||||
QUnit.test(testName + ' (SKIPPED)', function() {
|
||||
if (typeof callback === "function") {
|
||||
callback();
|
||||
}
|
||||
var $li = $('#' + QUnit.config.current.id);
|
||||
QUnit.done(function() {
|
||||
$li.addClass('skipped');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var tester = {
|
||||
|
||||
/************************************************
|
||||
JSHint testing
|
||||
************************************************/
|
||||
jsHintTest : function(name, sourceFile, options) {
|
||||
// Chrome & Opera don't allow ajax loading of script files
|
||||
if (QUnit.isLocal && /Chrome|Opera/.test(navigator.userAgent)) {
|
||||
return QUnit.testSkip(name, function(){
|
||||
ok( true, 'test cannot be done locally' );
|
||||
});
|
||||
}
|
||||
function validateFile(source) {
|
||||
var i, len, err,
|
||||
result = JSHINT(source, options),
|
||||
errors = JSHINT.errors;
|
||||
ok(result);
|
||||
if (result) {
|
||||
return;
|
||||
}
|
||||
for (i = 0, len = errors.length; i < len; i++) {
|
||||
err = errors[i];
|
||||
if (!err) {
|
||||
continue;
|
||||
}
|
||||
ok(false, err.reason + " on line " + err.line +
|
||||
", character " + err.character);
|
||||
}
|
||||
}
|
||||
return asyncTest(name, function() {
|
||||
$.ajax({
|
||||
url: sourceFile,
|
||||
dataType: 'script',
|
||||
success: function(source) {
|
||||
start();
|
||||
validateFile(source);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/************************************************
|
||||
test table data cache
|
||||
************************************************/
|
||||
cacheCompare : function(table, col, expected, txt, filtered){
|
||||
var i, j = 0, k, l,
|
||||
c = table.config,
|
||||
result = [],
|
||||
b = table.tBodies,
|
||||
l2 = c.columns;
|
||||
for (k = 0; k < b.length; k++){
|
||||
l = b[k].rows.length;
|
||||
for (j = 0; j < l; j++) {
|
||||
if (filtered && c.cache[k].normalized[j][c.columns].$row.hasClass('filtered')) {
|
||||
continue;
|
||||
}
|
||||
if (col === 'all') {
|
||||
// return all columns
|
||||
for (i = 0; i < l2; i++) {
|
||||
result.push( c.cache[k].normalized[j] ? c.cache[k].normalized[j][i] : '' );
|
||||
}
|
||||
} else {
|
||||
// return specific column
|
||||
result.push( c.cache[k].normalized[j] ? c.cache[k].normalized[j][col] : '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
deepEqual( result, expected, 'testing parser cache: ' + txt);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
Core plugin tested
|
||||
========================
|
||||
OPTIONS:
|
||||
cssAsc, cssChildRow, cssDesc, cssHeader, cssHeaderRow, cssInfoBlock, dateFormat, emptyTo, headerList,
|
||||
headers, ignoreCase, initialized, parsers, sortList, sortLocaleCompare, sortReset, stringTo, tableClass,
|
||||
usNumberFormat, widgets (just zebra), sortAppend, sortForce, sortMultiSortKey, sortResetKey, numberSorter
|
||||
|
||||
METHODS:
|
||||
addRows, applyWidgets, destroy, sorton, sortReset, update/updateRow, updateAll, updateCell
|
||||
|
||||
EVENTS:
|
||||
initialized, sortBegin, sortEnd, sortStart, updateComplete
|
||||
|
||||
Not yet tested
|
||||
=========================
|
||||
OPTIONS:
|
||||
cancelSelection, cssIcon, cssProcessing, debug, delayInit, headerTemplate, initWidgets, onRenderHeader,
|
||||
onRenderTemplate, selectorHeaders, selectorRemove, selectorSort, serverSideSorting, showProcessing,
|
||||
sortInitialOrder, sortRestart, strings,
|
||||
textExtraction, textSorter, theme, widthFixed, widgets (also need priority testing)
|
||||
|
||||
METHODS:
|
||||
appendCache, applyWidgetId, sort, refreshWidgets
|
||||
|
||||
EVENTS:
|
||||
-
|
||||
*/
|
||||
|
||||
$(function(){
|
||||
|
||||
var ts = $.tablesorter,
|
||||
$table1 = $('#table1'),
|
||||
$table2 = $('#table2'),
|
||||
$table3 = $('#table3'),
|
||||
$table4 = $('#table4'),
|
||||
$table5 = $('#table5'), // empty table
|
||||
table1 = $table1[0],
|
||||
table2 = $table2[0],
|
||||
table3 = $table3[0],
|
||||
table4 = $table4[0],
|
||||
table5 = $table5[0],
|
||||
th0 = $table1.find('th')[0], // first table header cell
|
||||
init = false,
|
||||
sortIndx = 0,
|
||||
updateIndx = 0,
|
||||
updateCallback = 0,
|
||||
events = ['sortStart', 'sortBegin', 'sortEnd', ' '],
|
||||
returnTime = function(string){
|
||||
return new Date(string).getTime();
|
||||
},
|
||||
undef, c1, c2, c3, c4, e, i, t;
|
||||
|
||||
$table1
|
||||
.bind('tablesorter-initialized', function(){
|
||||
init = true;
|
||||
})
|
||||
.tablesorter();
|
||||
|
||||
$table2.tablesorter({
|
||||
headers: {
|
||||
0: { sorter: 'text' },
|
||||
1: { sorter: 'text' },
|
||||
2: { sorter: false }
|
||||
}
|
||||
});
|
||||
|
||||
$table3.tablesorter({
|
||||
emptyTo: "bottom",
|
||||
stringTo: "max", // non-numeric content is treated as a MAX value
|
||||
headers: {
|
||||
0: { empty : "top" }, // sort empty cells to the top
|
||||
2: { string: "min" }, // non-numeric content is treated as a MIN value
|
||||
3: { sorter: "digit", empty : "zero", string : "top" }
|
||||
}
|
||||
});
|
||||
|
||||
$table4.tablesorter({
|
||||
sortAppend : [[2,0],[3,0]],
|
||||
sortForce : [[0,0],[1,0]],
|
||||
textExtraction : {
|
||||
'.te-test' : function(node){
|
||||
return $(node).find('span').text();
|
||||
},
|
||||
2 : function(node){
|
||||
return $(node).find('span').text();
|
||||
}
|
||||
},
|
||||
initialized: function(table){
|
||||
var e, c = table.config;
|
||||
// trigger sort on 5th column
|
||||
// this method is used because triggering a "sorton" would ignore sortForce/sortAppend
|
||||
c.$headers.eq(4).trigger('sort');
|
||||
e = $.Event('sort');
|
||||
e.which = 1;
|
||||
e.shiftKey = true;
|
||||
c.$headers.eq(5).trigger(e);
|
||||
},
|
||||
numberSorter: function(a, b, dir){
|
||||
return dir ? a-b : b-a;
|
||||
}
|
||||
});
|
||||
|
||||
$table5.tablesorter();
|
||||
|
||||
module('JSHint');
|
||||
/************************************************
|
||||
JSHint testing
|
||||
************************************************/
|
||||
// Run JSHint on main js files
|
||||
tester.jsHintTest('JSHint core', 'js/jquery.tablesorter.js');
|
||||
tester.jsHintTest('JSHint pager', 'addons/pager/jquery.tablesorter.pager.js');
|
||||
tester.jsHintTest('JSHint widgets', 'js/jquery.tablesorter.widgets.js');
|
||||
tester.jsHintTest('JSHint group widget', 'js/widgets/widget-grouping.js');
|
||||
tester.jsHintTest('JSHint scroller widget', 'js/widgets/widget-scroller.js');
|
||||
|
||||
module('core');
|
||||
/************************************************
|
||||
Initialization
|
||||
************************************************/
|
||||
test( "tablesorter loaded & initialized", function() {
|
||||
expect(3);
|
||||
equal( typeof ts, 'object', "tablesorter loaded");
|
||||
equal( table1.hasInitialized, true, "tablesorter initialized flag");
|
||||
equal( init, true, "tablesorter initialized event");
|
||||
});
|
||||
|
||||
c1 = table1.config;
|
||||
c2 = table2.config;
|
||||
c3 = table3.config;
|
||||
c4 = table4.config;
|
||||
|
||||
/************************************************
|
||||
Test column numbering
|
||||
************************************************/
|
||||
// later: include a table header with colspan & rowspan
|
||||
test( "column numbering", function() {
|
||||
expect(2);
|
||||
var internalColumn = true,
|
||||
dataColumn = true;
|
||||
$table4.find('thead th').each(function(i){
|
||||
internalColumn = internalColumn && this.column === i;
|
||||
dataColumn = dataColumn && $(this).attr('data-column') == i;
|
||||
});
|
||||
equal( internalColumn, true, "Correct internal column numbering" );
|
||||
equal( dataColumn, true, "Correct data-column attribute numbering" );
|
||||
});
|
||||
|
||||
/************************************************
|
||||
check isDigit function
|
||||
************************************************/
|
||||
var d = ts.isDigit;
|
||||
test( "isDigit", function() {
|
||||
expect(17);
|
||||
ok( d('-1'), "allow negative (-1)");
|
||||
ok( d('+1'), "allow plus (+1)");
|
||||
ok( d('(1)'), "allow parenthesis (1)");
|
||||
ok( d('123'), "string has numbers ('123')");
|
||||
ok( d(123), "has numbers (123)");
|
||||
ok( d('1.2'), "remove decimal (1.2)");
|
||||
ok( d('1,234'),"remove commas (1,234)");
|
||||
ok( d("11'"), "remove apostrophe's (11')"); // 11 feet
|
||||
ok( d('3\'4"'),"remove quotes (3'4\")"); // 3 foot 4 inches
|
||||
ok( d(' 12 '), "remove spaces ( 12 )");
|
||||
ok( !d('x'), "non-digit alphabet");
|
||||
ok( !d('1x'), "digit + alphabet");
|
||||
ok( !d('x1'), "alphabet + digit");
|
||||
ok( !d('@'), "non-digit symbols");
|
||||
ok( !d('1-'), "negative after (1-) not allowed?");
|
||||
ok( !d('1+'), "plus after (1+) not allowed?");
|
||||
ok( !d('$2'), "no money; the currency parser will catch these");
|
||||
});
|
||||
|
||||
/************************************************
|
||||
check formatFloat function
|
||||
************************************************/
|
||||
var ff = function(str) {
|
||||
return ts.formatFloat(str, table1);
|
||||
};
|
||||
test( "formatFloat", function() {
|
||||
expect(18);
|
||||
strictEqual( ff(''), '', 'returns empty string' );
|
||||
strictEqual( ff(5), 5, 'returns numerical values');
|
||||
|
||||
c1.usNumberFormat = false;
|
||||
strictEqual( ts.formatFloat('1,234,567.89'), 1234567.89, 'use format float without including table - defaults to US number format');
|
||||
|
||||
strictEqual( ff('1 234,56'), 1234.56, 'parse non-U.S. (French) number format');
|
||||
strictEqual( ff('1.234,56'), 1234.56, 'parse non-U.S. (German) number format');
|
||||
strictEqual( ff('-32,32'), -32.32, 'negative non-U.S. signed numbers');
|
||||
strictEqual( ff('-1.234,56'), -1234.56, 'negative non-U.S. signed numbers');
|
||||
strictEqual( ff('(32,32)'), -32.32, 'parenthesis wrapped non-U.S. negative number');
|
||||
strictEqual( ff(' (32,32) '), -32.32, 'space + parenthesis wrapped non-U.S. negative number');
|
||||
|
||||
c1.usNumberFormat = true;
|
||||
strictEqual( ff('1,234.56'), 1234.56, 'parse U.S. number format');
|
||||
strictEqual( ff('-32.32'), -32.32, 'negative U.S. signed numbers');
|
||||
strictEqual( ff('(32.32)'), -32.32, 'parenthesis wrapped U.S. negative number');
|
||||
strictEqual( ff(' (32.32)'), -32.32, 'space + parenthesis wrapped U.S. negative number');
|
||||
|
||||
strictEqual( ff('fred'), 'fred', 'return string if not a number');
|
||||
strictEqual( ff(' fred '), 'fred', 'return trimmed string if not a number');
|
||||
strictEqual( ff('fred 12'), 'fred 12', 'return string if number not at beginning');
|
||||
strictEqual( ff('12fred'), 12, 'parse number + string into number only');
|
||||
strictEqual( ff('(fred)'), '(fred)', 'leave parenthesis intact on strings');
|
||||
|
||||
});
|
||||
|
||||
/************************************************
|
||||
get data function - jQuery data > meta > headers option > header class name
|
||||
************************************************/
|
||||
var gd = function(n){
|
||||
return ts.getData( c2.$headers[n], c2.headers[n], 'sorter' );
|
||||
};
|
||||
|
||||
test( "getData", function() {
|
||||
expect(4);
|
||||
var txt = [ 'jQuery data', 'meta data', 'headers option', 'header class name' ];
|
||||
for (i = 0; i < 4; i++) {
|
||||
equal( gd(i), 'false', txt[i]); // all columns have sorter false set
|
||||
}
|
||||
});
|
||||
|
||||
/************************************************
|
||||
character equivalent replacement
|
||||
************************************************/
|
||||
test( "replace accents", function() {
|
||||
expect(6);
|
||||
strictEqual( ts.replaceAccents('\u00e1\u00e0\u00e2\u00e3\u00e4\u0105\u00e5\u00c1\u00c0\u00c2\u00c3\u00c4\u0104\u00c5'), 'aaaaaaaAAAAAAA', "replaced a's");
|
||||
strictEqual( ts.replaceAccents('\u00e9\u00e8\u00ea\u00eb\u011b\u0119\u00c9\u00c8\u00ca\u00cb\u011a\u0118'), 'eeeeeeEEEEEE', "replaced e's");
|
||||
strictEqual( ts.replaceAccents('\u00ed\u00ec\u0130\u00ee\u00ef\u0131\u00cd\u00cc\u0130\u00ce\u00cf'), 'iiiiiiIIiII', "replaced i's");
|
||||
strictEqual( ts.replaceAccents('\u00f3\u00f2\u00f4\u00f5\u00f6\u00d3\u00d2\u00d4\u00d5\u00d6'), 'oooooOOOOO', "replaced o's");
|
||||
strictEqual( ts.replaceAccents('\u00fa\u00f9\u00fb\u00fc\u016f\u00da\u00d9\u00db\u00dc\u016e'), 'uuuuuUUUUU', "replaced u's");
|
||||
strictEqual( ts.replaceAccents('\u00e7\u0107\u010d\u00c7\u0106\u010c\u00df\u1e9e'), 'cccCCCssSS', "replaced c & s sharp");
|
||||
});
|
||||
|
||||
/************************************************
|
||||
detect parsers
|
||||
************************************************/
|
||||
asyncTest( "detect parsers", function() {
|
||||
expect(2);
|
||||
$('#testblock2').html('<table class="tablesorter"><thead>' +
|
||||
'<tr><th class="col-off" colspan="2">Info</th><th class="col-off" colspan="4">Details</th></tr>' +
|
||||
'<tr>' +
|
||||
'<th class="col-first">First Name</th>' +
|
||||
'<th class="col-last">Last Name</th>' +
|
||||
'<th class="col-age" id="age">Age</th>' +
|
||||
'<th class="col-total">Total</th>' +
|
||||
'<th class="col-discount">Discount</th>' +
|
||||
'<th class="col-date">Date</th>' +
|
||||
'</tr></thead>' +
|
||||
'<tbody>' +
|
||||
'<tr><td>Peter</td><td>Parker</td><td>28</td><td>$9.99</td><td>20%</td><td>Jul 6, 2006 8:14 AM</td></tr>' +
|
||||
'<tr><td>John</td><td>Hood</td><td>33</td><td>$19.99</td><td>25%</td><td>Dec 10, 2002 5:14 AM</td></tr>' +
|
||||
'<tr><td>Clark</td><td>Kent</td><td>18</td><td>$15.89</td><td>44%</td><td>Jan 12, 2003 11:14 AM</td></tr>' +
|
||||
'<tr><td>Bruce</td><td>Almighty</td><td>45</td><td>$153.19</td><td>44%</td><td>Jan 18, 2001 9:12 AM</td></tr>' +
|
||||
'<tr><td>Bruce</td><td>Evans</td><td>22</td><td>$13.19</td><td>11%</td><td>Jan 18, 2007 9:12 AM</td></tr>' +
|
||||
'</tbody></table>')
|
||||
.find('table')
|
||||
.tablesorter({
|
||||
headers : {
|
||||
0 : { sorter: false },
|
||||
1 : { sorter: false },
|
||||
3 : { sorter: 'digit' } // 3 sets the 4th column, not the 3rd header cell now
|
||||
},
|
||||
initialized: function(table){
|
||||
start();
|
||||
var i,
|
||||
result = true,
|
||||
parsers = [ 'text', 'digit', 'digit', 'currency', 'percent', 'usLongDate' ],
|
||||
c = table.config;
|
||||
for (i = 0; i < c.columns; i++){
|
||||
result = result && c.parsers[i].id === parsers[i];
|
||||
}
|
||||
equal( result, true, 'detect parsers by header index' );
|
||||
stop();
|
||||
// table inception!
|
||||
$(table)
|
||||
.trigger('destroy')
|
||||
.tablesorter({
|
||||
headers : {
|
||||
'.col-first' : { sorter: 'url' },
|
||||
'.col-off' : { sorter: false },
|
||||
'.col-total' : { sorter : 'percent' },
|
||||
'#age, .col-last' : { sorter: 'currency' },
|
||||
'.col-date' : { sorter : 'time' },
|
||||
'.col-discount' : { sorter: 'digit' }
|
||||
},
|
||||
initialized: function(table){
|
||||
var i,
|
||||
result = true,
|
||||
parsers = [ 'url', 'currency', 'currency', 'percent', 'digit', 'time' ],
|
||||
c = table.config;
|
||||
for (i = 0; i < c.columns; i++){
|
||||
result = result && c.parsers[i].id === parsers[i];
|
||||
}
|
||||
equal( result, true, 'detect parsers by class/id' );
|
||||
start();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/************************************************
|
||||
check all default parsers
|
||||
************************************************/
|
||||
var p = ts.parsers,
|
||||
// test by parser
|
||||
parserTests = 85,
|
||||
// skipping metadata parser
|
||||
sample1 = {
|
||||
'text' : { 'test': 'test', 'TesT': 'test', '\u00e1 test': '\u00e1 test' },
|
||||
'currency' : { '\u00a31': 1, '($2.23)': -2.23, '5\u20ac': 5, '(11\u00a4)': -11, '500\u00a5': 500, '25\u00a2': 25, '$1,000.50': 1000.5 },
|
||||
'ipAddress' : { '255.255.255.255': 255255255255, '32.32.32.32': 32032032032, '1.1.1.1': 1001001001 },
|
||||
'url' : { 'http://google.com': 'google.com', 'ftp://fred.com': 'fred.com', 'https://github.com': 'github.com' },
|
||||
'isoDate' : { '2012/12/12': returnTime('2012/12/12'), '2012-12/12': returnTime('2012/12/12'), '2013-1-1': returnTime('2013/1/1'), '2013/1/1 12:34:56 AM': returnTime('2013/1/1 12:34:56 AM') },
|
||||
'percent' : { '100%': 100, '22%': 22, '%2': 2, '2 %': 2, '(4%)': -4, '1,234.56 %': 1234.56 },
|
||||
'usLongDate': { 'Feb 23, 1999': returnTime('Feb 23, 1999'), 'Feb 23, 1999 12:34': returnTime('Feb 23, 1999 12:34'), 'Feb 23, 1999 12:34 AM': returnTime('Feb 23, 1999 12:34 AM'), 'Feb 23, 1999 12:34:56 PM': returnTime('Feb 23, 1999 12:34:56 PM'), '01 Jan 2013': returnTime('01 Jan 2013') },
|
||||
'shortDate' : { '1/2/2001': returnTime('1/2/2001'), '1 2 2001': returnTime('1/2/2001'), '1.2.2001': returnTime('1/2/2001'), '1-2-2001': returnTime('1/2/2001'), '1/2/2001 12:34 PM' : returnTime('1/2/2001 12:34 PM'), '1.2.2001 13:34' : returnTime('1/2/2001 13:34') },
|
||||
'time' : { '12:34 AM': returnTime('2000/01/01 12:34 AM'), '1:00 pm': returnTime('2000/01/01 1:00 pm') },
|
||||
'digit' : { '12': 12, '$23': 23, '&44^': 44, '#(33)': -33, '1,000': 1000, '12.34': 12.34 }
|
||||
},
|
||||
// switch ignoreCase, sortLocalCompare & shortDate "ddmmyyyy"
|
||||
sample2 = {
|
||||
'text' : { 'TesT': 'TesT', '\u00e1 test': 'a test' },
|
||||
'currency' : { '\u20ac 123 456,78': 123456.78, '\u20ac 123.456,78': 123456.78 },
|
||||
'shortDate' : { '2/1/2001': returnTime('1/2/2001'), '2-1-2001': returnTime('1/2/2001'), '2 1,2001': returnTime('1/2/2001') }
|
||||
},
|
||||
// shortdate to "yyyymmdd"
|
||||
sample3 = {
|
||||
'shortDate' : { '2001/1/2': returnTime('1/2/2001'), '2001-1/2': returnTime('1/2/2001'), '2001,1.2': returnTime('1/2/2001') }
|
||||
},
|
||||
report = function(s) {
|
||||
for (i = 0; i < p.length; i++) {
|
||||
t = p[i].id;
|
||||
if (s.hasOwnProperty(t)) {
|
||||
/*jshint loopfunc:true */
|
||||
$.each(s[t], function(k,v){
|
||||
// check "is" and "format" functions
|
||||
if (p[i].is(k)) {
|
||||
equal( p[i].format(k, table1, th0, 0), v, t + ' parser: "' + k + '" parsed to ' + v );
|
||||
} else {
|
||||
equal( p[i].format(k, table1, th0, 0), v, t + ' parser **NOT DETECTED**: "' + k + '", but returns ' + v );
|
||||
}
|
||||
});
|
||||
// test for undefined & null - probably overkill
|
||||
strictEqual( p[i].format(undef, table1, th0, 0), undef, t + ' parser: will return undefined values properly' );
|
||||
strictEqual( p[i].format(null, table1, th0, 0), null, t + ' parser: will return null values properly' );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
test( "testing parsers", function() {
|
||||
expect(parserTests);
|
||||
report(sample1);
|
||||
|
||||
c1.sortLocaleCompare = true;
|
||||
c1.ignoreCase = false;
|
||||
c1.usNumberFormat = false;
|
||||
th0.dateFormat = c1.dateFormat = "ddmmyyyy";
|
||||
report(sample2);
|
||||
|
||||
c1.usNumberFormat = true;
|
||||
th0.dateFormat = c1.dateFormat = "yyyymmdd";
|
||||
report(sample3);
|
||||
|
||||
// undocumented sortValue
|
||||
equal( ts.getParserById('metadata').format(null, table1, th0, 0), 'zzz', 'metadata parser found sortValue');
|
||||
c1.parserMetadataName = 'poe';
|
||||
equal( ts.getParserById('metadata').format(null, table1, th0, 0), 'nevermore', 'metadata parser found poe');
|
||||
|
||||
});
|
||||
|
||||
test( "textExtraction Method", function() {
|
||||
expect(4);
|
||||
|
||||
$table1.trigger('sorton', [[[ 0,0 ]]]);
|
||||
tester.cacheCompare( table1, 0, [ 'test1', 'test2', 'test3', '', 'testa', 'testb', 'testc' ], 'from data-attribute' );
|
||||
|
||||
$table3.trigger('sorton', [[[ 0,1 ]]]);
|
||||
tester.cacheCompare( table3, 0, [ '', 'a255', 'a102', 'a87', 'a55', 'a43', 'a33', 'a10', 'a02', 'a1' ], 'ignore data-attribute' );
|
||||
|
||||
tester.cacheCompare( table4, 1, [ 'f11', 'f11', 'f12', 'f12', 'f12', 'f12', 'f12', 'f13', 'f13', 'f13' ], 'extract using class name' );
|
||||
|
||||
tester.cacheCompare( table4, 2, [ 'a21', 'a21', 'a23', 'a23', 'a23', 'a22', 'a22', 'a23', 'a24', 'a24' ], 'extract using column index' );
|
||||
|
||||
});
|
||||
|
||||
/************************************************
|
||||
test parser cache
|
||||
************************************************/
|
||||
test( "parser cache; sorton methods; empty & string", function() {
|
||||
expect(18);
|
||||
$table1.trigger('sortReset');
|
||||
|
||||
// lower case because table was parsed before c1.ignoreCase was changed
|
||||
tester.cacheCompare( table1, 'all', [ 'test2', 'x2', 'test1', 'x3', 'test3', 'x1', '', '', 'testb', 'x5', 'testc', 'x4', 'testa', 'x6' ], 'unsorted' );
|
||||
|
||||
$table1.trigger('sorton', [[[ 0,0 ]]]);
|
||||
tester.cacheCompare( table1, 'all', [ 'test1', 'x3', 'test2', 'x2', 'test3', 'x1', '', '', 'testa', 'x6', 'testb', 'x5', 'testc', 'x4' ], 'ascending sort' );
|
||||
|
||||
$table1.trigger('sorton', [[[ 0,1 ]]]);
|
||||
tester.cacheCompare( table1, 'all', [ 'test3', 'x1', 'test2', 'x2', 'test1', 'x3', '', '', 'testc', 'x4', 'testb', 'x5', 'testa', 'x6' ], 'descending sort' );
|
||||
|
||||
// empty cell position
|
||||
$table3.trigger('sorton', [[[ 0,0 ]]]);
|
||||
tester.cacheCompare( table3, 0, [ '', 'a1', 'a02', 'a10', 'a33', 'a43', 'a55', 'a87', 'a102', 'a255' ], 'asc sort; empty to top' );
|
||||
|
||||
$table3.trigger('sorton', [[[ 0,1 ]]]);
|
||||
tester.cacheCompare( table3, 0, [ '', 'a255', 'a102', 'a87', 'a55', 'a43', 'a33', 'a10', 'a02', 'a1' ], 'desc sort; empty to top' );
|
||||
|
||||
// string position within number column
|
||||
$table3.trigger('sorton', [[[ 1,0 ]]]);
|
||||
tester.cacheCompare( table3, 1, [ -35, -5, -1, 1, 2, 4, 33, 44, 'nr', '' ], 'asc sort; empty to bottom; string to max' );
|
||||
|
||||
$table3.trigger('sorton', [[[ 1,1 ]]]);
|
||||
tester.cacheCompare( table3, 1, [ 'nr', 44, 33, 4, 2, 1, -1, -5, -35, '' ], 'desc sort; empty to bottom; string to max' );
|
||||
|
||||
$table3.trigger('sorton', [[[ 2,0 ]]]);
|
||||
tester.cacheCompare( table3, 2, [ 'nr', 'nr', 1, 2, 3, 4, 5, 6, 7, '' ], 'asc sort; empty to bottom; string to min' );
|
||||
|
||||
$table3.trigger('sorton', [[[ 2,1 ]]]);
|
||||
tester.cacheCompare( table3, 2, [ 7, 6, 5, 4, 3, 2, 1, 'nr', 'nr', '' ], 'desc sort; empty to bottom; string to min' );
|
||||
|
||||
$table3.trigger('sorton', [[[ 3,0 ]]]);
|
||||
tester.cacheCompare( table3, 3, [ 'n/a #2', 'n/a #1', -8.4, -2.2, -0.1, '', 5.2, 11.4, 23.6, 97.4 ], 'asc sort; empty to zero; string to top' );
|
||||
|
||||
$table3.trigger('sorton', [[[ 3,1 ]]]);
|
||||
tester.cacheCompare( table3, 3, [ 'n/a #2', 'n/a #1', 97.4, 23.6, 11.4, 5.2, '', -0.1, -2.2, -8.4 ], 'desc sort; empty to zero; string to top' );
|
||||
|
||||
$table3.find('th:eq(3)').data('string', 'bottom');
|
||||
$table3.trigger('update');
|
||||
tester.cacheCompare( table3, 3, [ 97.4, 23.6, 11.4, 5.2, '', -0.1, -2.2, -8.4, 'n/a #1', 'n/a #2' ], 'desc sort; empty to zero; string to bottom' );
|
||||
|
||||
$table3.trigger('sorton', [[[ 3,0 ]]]);
|
||||
tester.cacheCompare( table3, 3, [ -8.4, -2.2, -0.1, '', 5.2, 11.4, 23.6, 97.4, 'n/a #1', 'n/a #2' ], 'asc sort; empty to zero; string to bottom' );
|
||||
|
||||
$table3.find('th:eq(3)').data('string', 'none');
|
||||
c3.headers[3].empty = "bottom";
|
||||
c3.sortList = [[ 3, 1 ]]; // added to test sortList
|
||||
$table3.trigger('update');
|
||||
tester.cacheCompare( table3, 3, [ 97.4, 23.6, 11.4, 5.2, 'n/a #1', 'n/a #2', -0.1, -2.2, -8.4, '' ], 'desc sort; empty to zero; string to none/zero' );
|
||||
|
||||
$table3.trigger('sorton', [[[ 3,0 ]]]);
|
||||
tester.cacheCompare( table3, 3, [ -8.4, -2.2, -0.1, 'n/a #1', 'n/a #2', 5.2, 11.4, 23.6, 97.4, '' ], 'asc sort; empty to zero; string to none/zero' );
|
||||
|
||||
t = [ 'x', 'X', 'y', 'Y', 'z', 'Z', 'a', 'A', 'b', 'B', 'c', 'C' ];
|
||||
deepEqual( t.sort($.tablesorter.sortText), [ 'A', 'B', 'C', 'X', 'Y', 'Z', 'a', 'b', 'c', 'x', 'y', 'z' ], 'test sortText function directly' );
|
||||
|
||||
t = [ 'a02', 'a10', 'a43', 'a255', 'a102', 'a33', '', 'a1', 'a55', 'a87' ];
|
||||
deepEqual( t.sort($.tablesorter.sortNatural), [ '', 'a1', 'a02', 'a10', 'a33', 'a43', 'a55', 'a87', 'a102', 'a255' ], 'test sortNatural function directly' );
|
||||
|
||||
tester.cacheCompare( table4, 6, [ '', '', '', '', '', '', '', '', '', '' ], 'parser-false does not extract text' );
|
||||
|
||||
});
|
||||
|
||||
test( "sorton methods", function(){
|
||||
expect(6);
|
||||
|
||||
$table3.trigger('sorton', [[[ 0,'d' ]]]);
|
||||
equal( c3.sortList + '', '0,1', 'sorton desc [0,"d"]' );
|
||||
|
||||
$table3.trigger('sorton', [[[ 0,'a' ]]]);
|
||||
equal( c3.sortList + '', '0,0', 'sorton asc [0,"a"]' );
|
||||
|
||||
$table3.trigger('sorton', [[[ 0,'n' ]]]);
|
||||
equal( c3.sortList + '', '0,1', 'sorton next [0,"n"]' );
|
||||
$table3.trigger('sorton', [[[ 0,'n' ]]]);
|
||||
equal( c3.sortList + '', '0,0', 'sorton next [0,"n"]' );
|
||||
|
||||
$table3.trigger('sorton', [[ [ 0,'n'], [1,'o'], [2,'s'] ]]);
|
||||
equal( c3.sortList + '', '0,1,1,0,2,1', 'sorton next/opposite/same [0,"n"],[1,"o"],[2,"s"]' );
|
||||
|
||||
$table3.trigger('sorton', [[ [ 0,'n'], [1,'o'], [2,'s'] ]]);
|
||||
equal( c3.sortList + '', '0,0,1,1,2,0', 'sorton next/opposite/same [0,"n"],[1,"o"],[2,"s"]' );
|
||||
|
||||
});
|
||||
|
||||
test( "sort Events", function(){
|
||||
expect(1);
|
||||
|
||||
$table1.add($table5).bind( events.join('.testing '), function(e){
|
||||
if (e.type === events[sortIndx%3]) {
|
||||
sortIndx++;
|
||||
}
|
||||
});
|
||||
|
||||
$table1.trigger('sorton', [[[ 0,0 ]]]);
|
||||
$table1.trigger('sorton', [[[ 1,0 ]]]);
|
||||
|
||||
// ensure all sort events fire on an empty table
|
||||
$table5.trigger('sorton', [ [[0,0]] ]);
|
||||
|
||||
$table1.add($table5).unbind( events.join('.testing ') );
|
||||
|
||||
// table1 sorted twice in the above test; sortIndx = 9 then empty table5 x1 (total = 3 events x 3)
|
||||
equal( sortIndx, 9, 'sortStart, sortBegin & sortEnd fired in order x2; including empty table' );
|
||||
});
|
||||
|
||||
/************************************************
|
||||
test update methods
|
||||
************************************************/
|
||||
test( "parser cache; update methods & callbacks", function() {
|
||||
expect(10);
|
||||
var oldColMax;
|
||||
c1.ignoreCase = true;
|
||||
// updateAll
|
||||
$table1
|
||||
.trigger('sorton', [ [[0,1]] ])
|
||||
.bind('updateComplete.testing', function(){ updateIndx++; })
|
||||
.find('th:eq(1)').removeAttr('class').html('num').end()
|
||||
.find('td:nth-child(2)').html(function(i,h){
|
||||
return h.substring(1);
|
||||
});
|
||||
$table1
|
||||
.trigger('updateAll', [false, function(){
|
||||
updateCallback++;
|
||||
var nw = $table1.find('th:eq(1)')[0],
|
||||
hc = c1.headerContent[1] === 'num',
|
||||
hd = c1.$headers[1] === nw,
|
||||
hl = c1.headerList[1] === nw,
|
||||
p1 = c1.parsers[1].id === 'digit';
|
||||
equal(hc && hd && hl && p1, true, 'testing header cache: updateAll - thead');
|
||||
tester.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3, '', '', 'testc', 4, 'testb', 5, 'testa', 6 ], 'updateAll - tbody' );
|
||||
}]);
|
||||
|
||||
// addRows
|
||||
t = $('<tr class="temp"><td>testd</td><td>7</td></tr>');
|
||||
$table1.find('tbody:last').prepend(t);
|
||||
oldColMax = c1.cache[2].colMax[1];
|
||||
$table1.trigger('addRows', [t, true, function(){
|
||||
updateCallback++;
|
||||
equal( oldColMax === 6 && c1.cache[2].colMax[1] === 7, true, 'addRows includes updating colMax value');
|
||||
tester.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3, '', '', 'testd', 7, 'testc', 4, 'testb', 5, 'testa', 6 ], 'addRows method' );
|
||||
}]);
|
||||
|
||||
// updateCell
|
||||
t = $table1.find('td:contains("7")');
|
||||
t.html('-8');
|
||||
oldColMax = c1.cache[2].colMax[1];
|
||||
$table1.trigger('updateCell', [t[0], true, function(){
|
||||
updateCallback++;
|
||||
equal( oldColMax === 7 && c1.cache[2].colMax[1] === 8, true, 'updateCell includes updating colMax value');
|
||||
tester.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3, '', '', 'testd', -8, 'testc', 4, 'testb', 5, 'testa', 6 ], 'updateCell method' );
|
||||
}]);
|
||||
|
||||
// update
|
||||
$table1.find('tr.temp').remove();
|
||||
oldColMax = c1.cache[2].colMax[1];
|
||||
$table1.trigger('update', [true, function(){
|
||||
updateCallback++;
|
||||
equal( oldColMax === 8 && c1.cache[2].colMax[1] === 6, true, 'update includes updating colMax value');
|
||||
tester.cacheCompare( table1, 'all', [ 'test3', 1, 'test2', 2, 'test1', 3, '', '', 'testc', 4, 'testb', 5, 'testa', 6 ], 'update method' );
|
||||
}]);
|
||||
|
||||
$table5
|
||||
.bind('updateComplete.testing', function(){ updateIndx++; })
|
||||
.trigger('update', [true, function(){
|
||||
updateCallback++;
|
||||
tester.cacheCompare( table5, 'all', [], 'update method on empty table' );
|
||||
}]);
|
||||
|
||||
$table1.add($table5).unbind('updateComplete.testing');
|
||||
|
||||
// table1 updated 4x in the above test
|
||||
// table5 updated 1x
|
||||
equal( updateIndx, updateCallback, 'updatedComplete and update callback functions working properly' );
|
||||
|
||||
});
|
||||
|
||||
/************************************************
|
||||
test sortForce, sortAppend, sortMultiSortKey and sortResetKey options
|
||||
************************************************/
|
||||
asyncTest( "sortForce, sortAppend, sortMultiSortKey & sortResetKey; and numberSorter option", function(){
|
||||
expect(3);
|
||||
var count = 0;
|
||||
tester.cacheCompare( table4, 3, [ 2, 1, 7, 6, 5, 3, 4, 8, 9, 10 ], 'force x2 + sorted x2 + append x2, ascending' );
|
||||
$table4.on('sortEnd', function(){
|
||||
count++;
|
||||
if (count === 1) {
|
||||
tester.cacheCompare( table4, 3, [ 2, 1, 6, 7, 5, 4, 3, 8, 10, 9 ], 'force x2 + sorted x2 + append x2, descending' );
|
||||
c4.sortResetKey = 'shiftKey';
|
||||
var e = $.Event('sort');
|
||||
e.which = 1;
|
||||
e.shiftKey = true; // testing sortResetKey
|
||||
c4.$headers.eq(0).trigger(e);
|
||||
} else {
|
||||
tester.cacheCompare( table4, 3, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'sortResetKey' );
|
||||
$table4.off('sortEnd');
|
||||
start();
|
||||
}
|
||||
});
|
||||
var e = $.Event('sort');
|
||||
c4.sortMultiSortKey = 'altKey';
|
||||
e.which = 1;
|
||||
e.altKey = true; // testing sortMultiSortKey
|
||||
c4.$headers.eq(5).trigger(e);
|
||||
});
|
||||
|
||||
/************************************************
|
||||
check header css
|
||||
************************************************/
|
||||
test( "testing header css & sortReset method", function(){
|
||||
expect(7);
|
||||
t = $(th0);
|
||||
equal( $table1.hasClass(ts.css.table), true, 'table class applied');
|
||||
equal( t.hasClass(ts.css.header), true, 'Header class present' );
|
||||
equal( t.parent().hasClass(ts.css.headerRow), true, 'Header row class present' );
|
||||
equal( $table1.find('tbody:eq(1)').hasClass(c1.cssInfoBlock), true, 'Tbody info block class present' );
|
||||
$table1.trigger('sorton', [[[ 0,1 ]]] );
|
||||
equal( t.hasClass(ts.css.sortDesc), true, 'Descending class present' );
|
||||
$table1.trigger('sorton', [[[ 0,0 ]]] );
|
||||
equal( t.hasClass(ts.css.sortAsc), true, 'Ascending class present' );
|
||||
$table1.trigger('sortReset');
|
||||
equal( t.hasClass(ts.css.sortAsc) || t.hasClass(ts.css.sortDesc), false, 'Testing sortReset' );
|
||||
});
|
||||
|
||||
/************************************************
|
||||
test apply widgets function using zebra widget
|
||||
************************************************/
|
||||
var zebra = function(){
|
||||
t = true;
|
||||
var classes = ['odd','even'];
|
||||
$table2.find('tbody tr').each(function(i){
|
||||
t = t ? $(this).hasClass( classes[i%2] ) : false;
|
||||
});
|
||||
return t;
|
||||
};
|
||||
|
||||
test( "apply zebra widget", function(){
|
||||
expect(3);
|
||||
equal( zebra(), false, 'zebra not applied' );
|
||||
c2.widgets = [ 'zebra' ];
|
||||
$table2.trigger('applyWidgets');
|
||||
equal( zebra(), true, 'zebra is applied' );
|
||||
$table2
|
||||
.append('<tr><td>s</td><td>t</td><td>u</td><td>v</td></tr>')
|
||||
.trigger('update');
|
||||
equal( zebra(), true, 'zebra is applied after update' );
|
||||
});
|
||||
|
||||
/************************************************
|
||||
check destroy method
|
||||
************************************************/
|
||||
test("testing destroy method", function(){
|
||||
$table2.trigger('sorton', [[[ 0,1 ]]] );
|
||||
$table2.trigger('destroy');
|
||||
expect(7);
|
||||
t = $table2.find('th:first');
|
||||
e = jQuery._data(table2, 'events'); // get a list of all bound events
|
||||
equal( $.isEmptyObject(e), true, 'no events applied' );
|
||||
equal( $table2.data().hasOwnProperty('tablesorter'), false, 'Data removed' );
|
||||
equal( $table2.attr('class'), 'tester', 'All table classes removed' );
|
||||
equal( $table2.find('tr:first').attr('class'), '', 'Header row class removed' );
|
||||
equal( t.attr('class').match('tablesorter'), null, 'Header classes removed' );
|
||||
equal( t.children().length, 0, 'Inner wrapper removed' );
|
||||
equal( typeof (t.data().column) , 'undefined', 'data-column removed');
|
||||
|
||||
$table2.tablesorter();
|
||||
});
|
||||
|
||||
/************************************************
|
||||
ipv6 parser testing
|
||||
************************************************/
|
||||
ipv6tests();
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user