Files
hiscaler-gox/pathx/path_test.go

26 lines
553 B
Go
Raw Permalink Normal View History

2025-04-08 19:16:39 +02:00
package pathx
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestFilenameWithoutExt(t *testing.T) {
testCases := []struct {
tag string
path string
expected string
}{
{"t1", "a.jpg", "a"},
{"t2", "/a/b/c.jpg", "c"},
{"t3", "/a/b/c", "c"},
{"t4", "/a/b/c/", "c"},
{"t5", "/a/b/c/中文.jpg", "中文"},
{"t5", "https://www.example.com/a/b/c/中文.jpg", "中文"},
}
for _, testCase := range testCases {
v := FilenameWithoutExt(testCase.path)
assert.Equal(t, testCase.expected, v, testCase.tag)
}
}