6 lines
424 B
Go
6 lines
424 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestNormalizeDomain(t *testing.T){tests:=[]struct{in,want string;ok bool}{{"https://WWW.Example.com/path","www.example.com",true},{"example.com/","example.com",true},{"localhost","",false},{"127.0.0.1","",false},{"bad_domain.com","",false}};for _,tt:=range tests{got,err:=normalizeDomain(tt.in);if (err==nil)!=tt.ok||got!=tt.want{t.Errorf("normalizeDomain(%q)=(%q,%v)",tt.in,got,err)}}}
|