github.com/TeaOSLab/EdgeNode@v1.3.8/internal/utils/path_test.go (about) 1 package utils 2 3 import ( 4 "github.com/iwind/TeaGo/assert" 5 "testing" 6 ) 7 8 func TestCleanPath(t *testing.T) { 9 a := assert.NewAssertion(t) 10 11 a.IsTrue(CleanPath("") == "/") 12 a.IsTrue(CleanPath("/hello/world") == "/hello/world") 13 a.IsTrue(CleanPath("\\hello\\world") == "/hello/world") 14 a.IsTrue(CleanPath("/\\hello\\//world") == "/hello/world") 15 a.IsTrue(CleanPath("hello/world") == "/hello/world") 16 a.IsTrue(CleanPath("/hello////world") == "/hello/world") 17 } 18 19 func TestCleanPath_Args(t *testing.T) { 20 a := assert.NewAssertion(t) 21 a.IsTrue(CleanPath("/hello/world?base=///////") == "/hello/world?base=///////") 22 } 23 24 func BenchmarkCleanPath(b *testing.B) { 25 for i := 0; i < b.N; i++ { 26 _ = CleanPath("/hello///world/very/long/very//long") 27 } 28 }