add more testcases

This commit is contained in:
Miek Gieben 2012-09-18 08:19:06 +02:00
parent 10c0672a99
commit 1b7b7d6f74
2 changed files with 15 additions and 5 deletions

View File

@ -157,7 +157,7 @@ func main() {
defer pprof.StopCPUProfile()
}
dns.HandleFunc("miek.nl.", handleReflect)
dns.HandleFunc(".", handleReflect)
dns.HandleFunc("authors.bind.", dns.HandleAuthors)
dns.HandleFunc("authors.server.", dns.HandleAuthors)
dns.HandleFunc("version.bind.", dns.HandleVersion)

View File

@ -76,13 +76,23 @@ func TestDotAsCatchAllWildcard(t *testing.T) {
mux.Handle(".", HandlerFunc(HelloServer))
mux.Handle("example.com.", HandlerFunc(AnotherHelloServer))
handler := mux.match("www.mike.nl", TypeTXT)
handler := mux.match("www.miek.nl.", TypeTXT)
if handler == nil {
t.Error("wildcard match failed")
}
nhandler := mux.match("www.example.com", TypeTXT)
if nhandler == nil {
t.Error("match failed")
handler = mux.match("www.example.com.", TypeTXT)
if handler == nil {
t.Error("example.com match failed")
}
handler = mux.match("a.www.example.com.", TypeTXT)
if handler == nil {
t.Error("a.www.example.com match failed")
}
handler = mux.match("boe.", TypeTXT)
if handler == nil {
t.Error("boe. match failed")
}
}