MCPcopy
hub / github.com/rclone/rclone / testEncodeFileName

Function testEncodeFileName

backend/crypt/cipher_test.go:54–70  ·  view source on GitHub ↗
(t *testing.T, encoding string, testCases []EncodingTestCase, caseInsensitive bool)

Source from the content-addressed store, hash-verified

52}
53
54func testEncodeFileName(t *testing.T, encoding string, testCases []EncodingTestCase, caseInsensitive bool) {
55 for _, test := range testCases {
56 enc, err := NewNameEncoding(encoding)
57 assert.NoError(t, err, "There should be no error creating name encoder for base32.")
58 actual := enc.EncodeToString([]byte(test.in))
59 assert.Equal(t, actual, test.expected, fmt.Sprintf("in=%q", test.in))
60 recovered, err := enc.DecodeString(test.expected)
61 assert.NoError(t, err)
62 assert.Equal(t, string(recovered), test.in, fmt.Sprintf("reverse=%q", test.expected))
63 if caseInsensitive {
64 in := strings.ToUpper(test.expected)
65 recovered, err = enc.DecodeString(in)
66 assert.NoError(t, err)
67 assert.Equal(t, string(recovered), test.in, fmt.Sprintf("reverse=%q", in))
68 }
69 }
70}
71
72func TestEncodeFileNameBase32(t *testing.T) {
73 testEncodeFileName(t, "base32", []EncodingTestCase{

Callers 3

TestEncodeFileNameBase32Function · 0.85
TestEncodeFileNameBase64Function · 0.85

Calls 4

NewNameEncodingFunction · 0.85
EncodeToStringMethod · 0.65
DecodeStringMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…