@@ -76,39 +76,58 @@ def test_equality_with_internals
7676 end
7777 # rubocop:enable Style/SingleLineMethods
7878
79- def test_match
79+ def test_match_standard
8080 [
81- # standard match
8281 [ PublicSuffix ::Rule . factory ( "uk" ) , "uk" , true ] ,
8382 [ PublicSuffix ::Rule . factory ( "uk" ) , "example.uk" , true ] ,
8483 [ PublicSuffix ::Rule . factory ( "uk" ) , "example.co.uk" , true ] ,
8584 [ PublicSuffix ::Rule . factory ( "co.uk" ) , "example.co.uk" , true ] ,
85+ ] . each do |rule , input , expected |
86+ assert_equal expected , rule . match? ( input )
87+ end
88+ end
8689
90+ def test_match_wildcard_and_exception
91+ [
8792 # FIXME
8893 # [PublicSuffix::Rule.factory("*.com"), "com", false],
8994 [ PublicSuffix ::Rule . factory ( "*.com" ) , "example.com" , true ] ,
9095 [ PublicSuffix ::Rule . factory ( "*.com" ) , "foo.example.com" , true ] ,
9196 [ PublicSuffix ::Rule . factory ( "!example.com" ) , "com" , false ] ,
9297 [ PublicSuffix ::Rule . factory ( "!example.com" ) , "example.com" , true ] ,
9398 [ PublicSuffix ::Rule . factory ( "!example.com" ) , "foo.example.com" , true ] ,
99+ ] . each do |rule , input , expected |
100+ assert_equal expected , rule . match? ( input )
101+ end
102+ end
94103
95- # TLD mismatch
104+ def test_match_tld_mismatch
105+ [
96106 [ PublicSuffix ::Rule . factory ( "gk" ) , "example.uk" , false ] ,
97107 [ PublicSuffix ::Rule . factory ( "gk" ) , "example.co.uk" , false ] ,
98108 [ PublicSuffix ::Rule . factory ( "co.uk" ) , "uk" , false ] ,
109+ ] . each do |rule , input , expected |
110+ assert_equal expected , rule . match? ( input )
111+ end
112+ end
99113
100- # general mismatch
114+ def test_match_general_mismatch
115+ [
101116 [ PublicSuffix ::Rule . factory ( "uk.co" ) , "example.co.uk" , false ] ,
102117 [ PublicSuffix ::Rule . factory ( "go.uk" ) , "example.co.uk" , false ] ,
103118 [ PublicSuffix ::Rule . factory ( "co.uk" ) , "uk" , false ] ,
119+ ] . each do |rule , input , expected |
120+ assert_equal expected , rule . match? ( input )
121+ end
122+ end
104123
105- # partial matches/mismatches
124+ def test_match_partial
125+ [
106126 [ PublicSuffix ::Rule . factory ( "co" ) , "example.co.uk" , false ] ,
107127 [ PublicSuffix ::Rule . factory ( "example" ) , "example.uk" , false ] ,
108128 [ PublicSuffix ::Rule . factory ( "le.it" ) , "example.it" , false ] ,
109129 [ PublicSuffix ::Rule . factory ( "le.it" ) , "le.it" , true ] ,
110130 [ PublicSuffix ::Rule . factory ( "le.it" ) , "foo.le.it" , true ] ,
111-
112131 ] . each do |rule , input , expected |
113132 assert_equal expected , rule . match? ( input )
114133 end
0 commit comments