1package main 2 3import ( 4 "testing" 5) 6 7func TestValidURL(t *testing.T) { 8 tests := []struct { 9 url string 10 want bool 11 }{ 12 {"http://test.com", true}, 13 {"https://test.com", true}, 14 {"HttPs://test.com", true}, 15 {"/test/test.com", false}, 16 {"", false}, 17 } 18 19 for _, test := range tests { 20 have := validURL(test.url) 21 if have != test.want { 22 t.Errorf("Want %t for validURL(%s); have %t", test.want, test.url, have) 23 } 24 } 25} 26