mirror of
https://github.com/rclone/rclone.git
synced 2024-11-23 08:54:10 +01:00
45 lines
1.4 KiB
Go
45 lines
1.4 KiB
Go
|
package dropbox
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestInternalCheckPathLength(t *testing.T) {
|
||
|
rep := func(n int, r rune) (out string) {
|
||
|
rs := make([]rune, n)
|
||
|
for i := range rs {
|
||
|
rs[i] = r
|
||
|
}
|
||
|
return string(rs)
|
||
|
}
|
||
|
for _, test := range []struct {
|
||
|
in string
|
||
|
ok bool
|
||
|
}{
|
||
|
{in: "", ok: true},
|
||
|
{in: rep(maxFileNameLength, 'a'), ok: true},
|
||
|
{in: rep(maxFileNameLength+1, 'a'), ok: false},
|
||
|
{in: rep(maxFileNameLength, '£'), ok: true},
|
||
|
{in: rep(maxFileNameLength+1, '£'), ok: false},
|
||
|
{in: rep(maxFileNameLength, '☺'), ok: true},
|
||
|
{in: rep(maxFileNameLength+1, '☺'), ok: false},
|
||
|
{in: rep(maxFileNameLength, '你'), ok: true},
|
||
|
{in: rep(maxFileNameLength+1, '你'), ok: false},
|
||
|
{in: "/ok/ok", ok: true},
|
||
|
{in: "/ok/" + rep(maxFileNameLength, 'a') + "/ok", ok: true},
|
||
|
{in: "/ok/" + rep(maxFileNameLength+1, 'a') + "/ok", ok: false},
|
||
|
{in: "/ok/" + rep(maxFileNameLength, '£') + "/ok", ok: true},
|
||
|
{in: "/ok/" + rep(maxFileNameLength+1, '£') + "/ok", ok: false},
|
||
|
{in: "/ok/" + rep(maxFileNameLength, '☺') + "/ok", ok: true},
|
||
|
{in: "/ok/" + rep(maxFileNameLength+1, '☺') + "/ok", ok: false},
|
||
|
{in: "/ok/" + rep(maxFileNameLength, '你') + "/ok", ok: true},
|
||
|
{in: "/ok/" + rep(maxFileNameLength+1, '你') + "/ok", ok: false},
|
||
|
} {
|
||
|
|
||
|
err := checkPathLength(test.in)
|
||
|
assert.Equal(t, test.ok, err == nil, test.in)
|
||
|
}
|
||
|
}
|