You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudreve/pkg/util/path_test.go

37 lines
985 B

package util
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestDotPathToStandardPath(t *testing.T) {
asserts := assert.New(t)
asserts.Equal("/", DotPathToStandardPath(""))
asserts.Equal("/目录", DotPathToStandardPath("目录"))
asserts.Equal("/目录/目录2", DotPathToStandardPath("目录,目录2"))
}
func TestFillSlash(t *testing.T) {
asserts := assert.New(t)
asserts.Equal("/", FillSlash("/"))
asserts.Equal("/", FillSlash(""))
asserts.Equal("/123/", FillSlash("/123"))
}
func TestRemoveSlash(t *testing.T) {
asserts := assert.New(t)
asserts.Equal("/", RemoveSlash("/"))
asserts.Equal("/123/1236", RemoveSlash("/123/1236"))
asserts.Equal("/123/1236", RemoveSlash("/123/1236/"))
}
func TestSplitPath(t *testing.T) {
asserts := assert.New(t)
asserts.Equal([]string{}, SplitPath(""))
asserts.Equal([]string{}, SplitPath("1"))
asserts.Equal([]string{"/"}, SplitPath("/"))
asserts.Equal([]string{"/", "123", "321"}, SplitPath("/123/321"))
}