Navigation Menu

Skip to content

Commit

Permalink
Path matching tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin committed Nov 9, 2014
1 parent 4c2e8d6 commit d038cd4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions servmux_test.go
Expand Up @@ -39,3 +39,24 @@ func TestPathMatching(t *testing.T) {
t.Errorf("Expected 1 message for /b, got %v", msgs["b"])
}
}

func TestPathMatch(t *testing.T) {
tests := []struct {
pattern, path string
exp bool
}{
{"", "", false},
{"/a/b/c", "/a/b/c", true},
{"/a/b/c", "/a/b/c/d", false},
{"/a/b/c/", "/a/b/c/d", true},
{"/a/b/c", "/", false},
{"/a/", "/", false},
}

for _, test := range tests {
if pathMatch(test.pattern, test.path) != test.exp {
t.Errorf("Failed on pathMatch(%q, %q), wanted %v",
test.pattern, test.path, test.exp)
}
}
}

0 comments on commit d038cd4

Please sign in to comment.