File: publicsuffix_test.go

package info (click to toggle)
golang-github-weppos-publicsuffix-go 0.30.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 484 kB
  • sloc: makefile: 16; sh: 9
file content (56 lines) | stat: -rw-r--r-- 1,249 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package publicsuffix_test

import (
	"testing"

	wpsl "github.com/weppos/publicsuffix-go/net/publicsuffix"
	xpsl "golang.org/x/net/publicsuffix"
)

func TestPublicSuffix(t *testing.T) {
	testCases := []string{
		"example.com",
		"www.example.com",
		"example.co.uk",
		"www.example.co.uk",
		"example.blogspot.com",
		"www.example.blogspot.com",
		"parliament.uk",
		"www.parliament.uk",
		// not listed
		"www.example.test",
	}

	for _, testCase := range testCases {
		ws, wb := wpsl.PublicSuffix(testCase)
		xs, xb := xpsl.PublicSuffix(testCase)

		if ws != xs || wb != xb {
			t.Errorf("PublicSuffix(%v): x/psl -> (%v, %v) != w/psl -> (%v, %v)", testCase, xs, xb, ws, wb)
		}
	}
}

func TestEffectiveTLDPlusOne(t *testing.T) {
	testCases := []string{
		"example.com",
		"www.example.com",
		"example.co.uk",
		"www.example.co.uk",
		"example.blogspot.com",
		"www.example.blogspot.com",
		"parliament.uk",
		"www.parliament.uk",
		// not listed
		"www.example.test",
	}

	for _, testCase := range testCases {
		ws, we := wpsl.EffectiveTLDPlusOne(testCase)
		xs, xe := xpsl.EffectiveTLDPlusOne(testCase)

		if ws != xs || we != xe {
			t.Errorf("EffectiveTLDPlusOne(%v): x/psl -> (%v, %v) != w/psl -> (%v, %v)", testCase, xs, xe, ws, we)
		}
	}
}