Skip to content

Commit

Permalink
Update to new tests file.
Browse files Browse the repository at this point in the history
  • Loading branch information
myronmarston committed Apr 19, 2016
1 parent b40f4f8 commit b224686
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 86 deletions.
164 changes: 82 additions & 82 deletions data/tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,97 +2,97 @@
// https://creativecommons.org/publicdomain/zero/1.0/

// null input.
checkPublicSuffix(null, null);
null null
// Mixed case.
checkPublicSuffix('COM', null);
checkPublicSuffix('example.COM', 'example.com');
checkPublicSuffix('WwW.example.COM', 'example.com');
COM null
example.COM example.com
WwW.example.COM example.com
// Leading dot.
checkPublicSuffix('.com', null);
checkPublicSuffix('.example', null);
checkPublicSuffix('.example.com', null);
checkPublicSuffix('.example.example', null);
.com null
.example null
.example.com null
.example.example null
// Unlisted TLD.
checkPublicSuffix('example', null);
checkPublicSuffix('example.example', 'example.example');
checkPublicSuffix('b.example.example', 'example.example');
checkPublicSuffix('a.b.example.example', 'example.example');
example null
example.example example.example
b.example.example example.example
a.b.example.example example.example
// Listed, but non-Internet, TLD.
//checkPublicSuffix('local', null);
//checkPublicSuffix('example.local', null);
//checkPublicSuffix('b.example.local', null);
//checkPublicSuffix('a.b.example.local', null);
//local null
//example.local null
//b.example.local null
//a.b.example.local null
// TLD with only 1 rule.
checkPublicSuffix('biz', null);
checkPublicSuffix('domain.biz', 'domain.biz');
checkPublicSuffix('b.domain.biz', 'domain.biz');
checkPublicSuffix('a.b.domain.biz', 'domain.biz');
biz null
domain.biz domain.biz
b.domain.biz domain.biz
a.b.domain.biz domain.biz
// TLD with some 2-level rules.
checkPublicSuffix('com', null);
checkPublicSuffix('example.com', 'example.com');
checkPublicSuffix('b.example.com', 'example.com');
checkPublicSuffix('a.b.example.com', 'example.com');
checkPublicSuffix('uk.com', null);
checkPublicSuffix('example.uk.com', 'example.uk.com');
checkPublicSuffix('b.example.uk.com', 'example.uk.com');
checkPublicSuffix('a.b.example.uk.com', 'example.uk.com');
checkPublicSuffix('test.ac', 'test.ac');
com null
example.com example.com
b.example.com example.com
a.b.example.com example.com
uk.com null
example.uk.com example.uk.com
b.example.uk.com example.uk.com
a.b.example.uk.com example.uk.com
test.ac test.ac
// TLD with only 1 (wildcard) rule.
checkPublicSuffix('mm', null);
checkPublicSuffix('c.mm', null);
checkPublicSuffix('b.c.mm', 'b.c.mm');
checkPublicSuffix('a.b.c.mm', 'b.c.mm');
mm null
c.mm null
b.c.mm b.c.mm
a.b.c.mm b.c.mm
// More complex TLD.
checkPublicSuffix('jp', null);
checkPublicSuffix('test.jp', 'test.jp');
checkPublicSuffix('www.test.jp', 'test.jp');
checkPublicSuffix('ac.jp', null);
checkPublicSuffix('test.ac.jp', 'test.ac.jp');
checkPublicSuffix('www.test.ac.jp', 'test.ac.jp');
checkPublicSuffix('kyoto.jp', null);
checkPublicSuffix('test.kyoto.jp', 'test.kyoto.jp');
checkPublicSuffix('ide.kyoto.jp', null);
checkPublicSuffix('b.ide.kyoto.jp', 'b.ide.kyoto.jp');
checkPublicSuffix('a.b.ide.kyoto.jp', 'b.ide.kyoto.jp');
checkPublicSuffix('c.kobe.jp', null);
checkPublicSuffix('b.c.kobe.jp', 'b.c.kobe.jp');
checkPublicSuffix('a.b.c.kobe.jp', 'b.c.kobe.jp');
checkPublicSuffix('city.kobe.jp', 'city.kobe.jp');
checkPublicSuffix('www.city.kobe.jp', 'city.kobe.jp');
jp null
test.jp test.jp
www.test.jp test.jp
ac.jp null
test.ac.jp test.ac.jp
www.test.ac.jp test.ac.jp
kyoto.jp null
test.kyoto.jp test.kyoto.jp
ide.kyoto.jp null
b.ide.kyoto.jp b.ide.kyoto.jp
a.b.ide.kyoto.jp b.ide.kyoto.jp
c.kobe.jp null
b.c.kobe.jp b.c.kobe.jp
a.b.c.kobe.jp b.c.kobe.jp
city.kobe.jp city.kobe.jp
www.city.kobe.jp city.kobe.jp
// TLD with a wildcard rule and exceptions.
checkPublicSuffix('ck', null);
checkPublicSuffix('test.ck', null);
checkPublicSuffix('b.test.ck', 'b.test.ck');
checkPublicSuffix('a.b.test.ck', 'b.test.ck');
checkPublicSuffix('www.ck', 'www.ck');
checkPublicSuffix('www.www.ck', 'www.ck');
ck null
test.ck null
b.test.ck b.test.ck
a.b.test.ck b.test.ck
www.ck www.ck
www.www.ck www.ck
// US K12.
checkPublicSuffix('us', null);
checkPublicSuffix('test.us', 'test.us');
checkPublicSuffix('www.test.us', 'test.us');
checkPublicSuffix('ak.us', null);
checkPublicSuffix('test.ak.us', 'test.ak.us');
checkPublicSuffix('www.test.ak.us', 'test.ak.us');
checkPublicSuffix('k12.ak.us', null);
checkPublicSuffix('test.k12.ak.us', 'test.k12.ak.us');
checkPublicSuffix('www.test.k12.ak.us', 'test.k12.ak.us');
us null
test.us test.us
www.test.us test.us
ak.us null
test.ak.us test.ak.us
www.test.ak.us test.ak.us
k12.ak.us null
test.k12.ak.us test.k12.ak.us
www.test.k12.ak.us test.k12.ak.us
// IDN labels.
checkPublicSuffix('食狮.com.cn', '食狮.com.cn');
checkPublicSuffix('食狮.公司.cn', '食狮.公司.cn');
checkPublicSuffix('www.食狮.公司.cn', '食狮.公司.cn');
checkPublicSuffix('shishi.公司.cn', 'shishi.公司.cn');
checkPublicSuffix('公司.cn', null);
checkPublicSuffix('食狮.中国', '食狮.中国');
checkPublicSuffix('www.食狮.中国', '食狮.中国');
checkPublicSuffix('shishi.中国', 'shishi.中国');
checkPublicSuffix('中国', null);
食狮.com.cn 食狮.com.cn
食狮.公司.cn 食狮.公司.cn
www.食狮.公司.cn 食狮.公司.cn
shishi.公司.cn shishi.公司.cn
公司.cn null
食狮.中国 食狮.中国
www.食狮.中国 食狮.中国
shishi.中国 shishi.中国
中国 null
// Same as above, but punycoded.
checkPublicSuffix('xn--85x722f.com.cn', 'xn--85x722f.com.cn');
checkPublicSuffix('xn--85x722f.xn--55qx5d.cn', 'xn--85x722f.xn--55qx5d.cn');
checkPublicSuffix('www.xn--85x722f.xn--55qx5d.cn', 'xn--85x722f.xn--55qx5d.cn');
checkPublicSuffix('shishi.xn--55qx5d.cn', 'shishi.xn--55qx5d.cn');
checkPublicSuffix('xn--55qx5d.cn', null);
checkPublicSuffix('xn--85x722f.xn--fiqs8s', 'xn--85x722f.xn--fiqs8s');
checkPublicSuffix('www.xn--85x722f.xn--fiqs8s', 'xn--85x722f.xn--fiqs8s');
checkPublicSuffix('shishi.xn--fiqs8s', 'shishi.xn--fiqs8s');
checkPublicSuffix('xn--fiqs8s', null);
xn--85x722f.com.cn xn--85x722f.com.cn
xn--85x722f.xn--55qx5d.cn xn--85x722f.xn--55qx5d.cn
www.xn--85x722f.xn--55qx5d.cn xn--85x722f.xn--55qx5d.cn
shishi.xn--55qx5d.cn shishi.xn--55qx5d.cn
xn--55qx5d.cn null
xn--85x722f.xn--fiqs8s xn--85x722f.xn--fiqs8s
www.xn--85x722f.xn--fiqs8s xn--85x722f.xn--fiqs8s
shishi.xn--fiqs8s shishi.xn--fiqs8s
xn--fiqs8s null
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ defmodule Mix.Tasks.PublicSuffix.SyncFiles do
def run(_) do
File.mkdir_p!(@data_dir)
sync_file "https://publicsuffix.org/list/public_suffix_list.dat", "public_suffix_list.dat"
sync_file "https://raw.githubusercontent.com/publicsuffix/list/master/tests/test_psl.txt", "tests.txt"
sync_file "https://raw.githubusercontent.com/publicsuffix/list/master/tests/tests.txt", "tests.txt"
end

defp sync_file(remote_url, local_path) do
Expand Down
4 changes: 1 addition & 3 deletions test/generated_cases_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ defmodule PublicSuffix.TestCaseGenerator do
defp generate_test_case({{test_case_line, line_index}, group_case_index}, group_description) do
[input, registrable_domain_output] =
test_case_line
|> String.replace_prefix("checkPublicSuffix(", "")
|> String.replace_suffix(");", "")
|> String.split(", ")
|> String.split(" ")
|> Enum.map(&parse_arg/1)

%{
Expand Down

0 comments on commit b224686

Please sign in to comment.