1
0
Fork 0

Added a test for path parsing and benchmarks for newPath and newServePath.

This commit is contained in:
Alexander Andreev 2023-09-05 06:03:29 +04:00
parent c237f8c566
commit 3e6d03db1a
Signed by: Arav
GPG Key ID: D22A817D95815393
1 changed files with 30 additions and 0 deletions

View File

@ -124,3 +124,33 @@ func TestSubPaths(t *testing.T) {
t.Error(found, "Path", p, "should return 404")
}
}
func TestPathParsing(t *testing.T) {
p, err := newPath("/api/v1/../.")
if err != nil {
t.Error(err)
}
t.Log(p)
}
const testStr = "/api/v1/foo/bar/baz/abc/def/fucc/b0y/of/a/local/dungeon/master/got/his/ass/fisted/for/free/and/he/was/absolutely/happy/with/that/"
func BenchmarkPatternPathParsing(b *testing.B) {
for i := 0; i < b.N; i++ {
p, err := newPath(testStr)
if err != nil {
b.Fatal(err)
}
b.Log(len(p))
}
}
func BenchmarkServePathParsing(b *testing.B) {
for i := 0; i < b.N; i++ {
p, err := newServePath(testStr)
if err != nil {
b.Fatal(err)
}
b.Log(len(p))
}
}