From 1b7b7d6f742b26eba6daf121ea8dffcdd688f8f4 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Tue, 18 Sep 2012 08:19:06 +0200 Subject: [PATCH] add more testcases --- ex/reflect/reflect.go | 2 +- server_test.go | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ex/reflect/reflect.go b/ex/reflect/reflect.go index f07a26ed..f43b8a3b 100644 --- a/ex/reflect/reflect.go +++ b/ex/reflect/reflect.go @@ -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) diff --git a/server_test.go b/server_test.go index d8aa3c23..117b59aa 100644 --- a/server_test.go +++ b/server_test.go @@ -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") } }