Example #1
0
func TestSiteList(t *testing.T) {
	list := NewList(LIST_TUNNEL)

	sites := []string{
		"www.google.com",
		"www.github.com",
		"www.reddit.com",
	}
	sites2 := []string{
		"a.google.com",
		"b.github.com",
		"c.reddit.com",
	}
	sites3 := []string{
		"aoogle.com",
		"bithub.com",
		"ceddit.com",
	}

	list.Add(sites...)

	for _, site := range sites {
		testing2.True(t, list.Contains(site))
	}
	for _, site := range sites2 {
		testing2.True(t, list.Contains(site))
	}
	for _, site := range sites3 {
		testing2.False(t, list.Contains(site))
	}
}
Example #2
0
func TestHex2Uint(t *testing.T) {
	res, _ := Hex2Uint("0XAff")
	testing2.Eq(t, uint64(0xaff), res)

	res, err := Hex2Uint("0xzz")
	testing2.True(t, err != nil)

	res, _ = Hex2Uint("00fff")
	testing2.Eq(t, uint64(0xfff), res)
}
Example #3
0
func TestSuffixList(t *testing.T) {
	list := NewList(LIST_DIRECT_SUFFIXES)
	list.Add(".cn")

	sites2 := []string{
		"a.cn",
		".cn",
	}
	for _, site := range sites2 {
		testing2.True(t, list.Contains(site))
	}
}
Example #4
0
func TestRoute(t *testing.T) {
	rt := new(router)
	errors.Fatal(rt.Handle("/user.:format", MapHandler{}))
	errors.Fatal(rt.Handle("/v:version", MapHandler{}))
	errors.Fatal(rt.Handle("/vaa/:id", MapHandler{}))
	// errors.Fatal(rt.Handle("/vba/:id", EmptyHandlerFunc))
	// errors.Fatal(rt.Handle("/v0a/:id", EmptyHandlerFunc))
	rt.PrintRouteTree(os.Stdout)
	_, value := rt.matchOne("/user.json", nil)
	t.Log(value)
	rt, value = rt.matchOne("/vbc", nil)
	testing2.True(t, rt != nil)
	t.Log(value)
}