slightly improve printing of regexps in failed tests.

This commit is contained in:
Kamil Kisiel
2015-08-11 22:16:22 -07:00
parent e330fd08a3
commit 5112c33f3a

View File

@@ -7,11 +7,24 @@ package mux
import (
"fmt"
"net/http"
"strings"
"testing"
"github.com/gorilla/context"
)
func (r *Route) GoString() string {
matchers := make([]string, len(r.matchers))
for i, m := range r.matchers {
matchers[i] = fmt.Sprintf("%#v", m)
}
return fmt.Sprintf("&Route{matchers:[]matcher{%s}}", strings.Join(matchers, ", "))
}
func (r *routeRegexp) GoString() string {
return fmt.Sprintf("&routeRegexp{template: %q, matchHost: %t, matchQuery: %t, strictSlash: %t, regexp: regexp.MustCompile(%q), reverse: %q, varsN: %v, varsR: %v", r.template, r.matchHost, r.matchQuery, r.strictSlash, r.regexp.String(), r.reverse, r.varsN, r.varsR)
}
type routeTest struct {
title string // title of the test
route *Route // the route being tested