From 3e6d03db1a7920b6c43f5199685c88e3b1e21a80 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Tue, 5 Sep 2023 06:03:29 +0400 Subject: [PATCH] Added a test for path parsing and benchmarks for newPath and newServePath. --- httpr_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/httpr_test.go b/httpr_test.go index 128aafe..b379fde 100644 --- a/httpr_test.go +++ b/httpr_test.go @@ -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)) + } +}