1
mirror of https://github.com/rclone/rclone synced 2024-12-25 17:03:45 +01:00

fstests: only test with ASCII uppercase for case insensitive tests

Upper/lower case for multilingual is provider dependent so we don't go
there in the tests.
This commit is contained in:
Nick Craig-Wood 2021-01-27 14:22:10 +00:00
parent 4323ff8a63
commit 92b9dabf3c

View File

@ -307,6 +307,17 @@ func stringsContains(x string, ss []string) bool {
return false return false
} }
// toUpperASCII returns a copy of the string s with all Unicode
// letters mapped to their upper case.
func toUpperASCII(s string) string {
return strings.Map(func(r rune) rune {
if 'a' <= r && r <= 'z' {
r -= 'a' - 'A'
}
return r
}, s)
}
// Run runs the basic integration tests for a remote using the options passed in. // Run runs the basic integration tests for a remote using the options passed in.
// //
// They are structured in a hierarchical way so that dependencies for the tests can be created. // They are structured in a hierarchical way so that dependencies for the tests can be created.
@ -1008,10 +1019,12 @@ func Run(t *testing.T, opt *Opt) {
if !f.Features().CaseInsensitive { if !f.Features().CaseInsensitive {
t.Skip("Not Case Insensitive") t.Skip("Not Case Insensitive")
} }
obj := findObject(ctx, t, f, strings.ToUpper(file1.Path)) obj := findObject(ctx, t, f, toUpperASCII(file1.Path))
file1.Check(t, obj, f.Precision()) file1.Check(t, obj, f.Precision())
obj = findObject(ctx, t, f, strings.ToUpper(file2.Path)) t.Run("Dir", func(t *testing.T) {
file2.Check(t, obj, f.Precision()) obj := findObject(ctx, t, f, toUpperASCII(file2.Path))
file2.Check(t, obj, f.Precision())
})
}) })
// TestFsListFile1and2 tests two files present // TestFsListFile1and2 tests two files present