MCPcopy
hub / github.com/rclone/rclone / TestEncodeInvalidUnicode

Function TestEncodeInvalidUnicode

lib/encoder/encoder_test.go:120–176  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

118}
119
120func TestEncodeInvalidUnicode(t *testing.T) {
121 for i, tc := range []testCase{
122 {
123 mask: EncodeInvalidUtf8,
124 in: "\xBF",
125 out: "‛BF",
126 }, {
127 mask: EncodeInvalidUtf8,
128 in: "\xBF\xFE",
129 out: "‛BF‛FE",
130 }, {
131 mask: EncodeInvalidUtf8,
132 in: "a\xBF\xFEb",
133 out: "a‛BF‛FEb",
134 }, {
135 mask: EncodeInvalidUtf8,
136 in: "a\xBFξ\xFEb",
137 out: "a‛BFξ‛FEb",
138 }, {
139 mask: EncodeInvalidUtf8 | EncodeBackSlash,
140 in: "a\xBF\\\xFEb",
141 out: "a‛BF\‛FEb",
142 }, {
143 mask: 0,
144 in: "\xBF",
145 out: "\xBF",
146 }, {
147 mask: 0,
148 in: "\xBF\xFE",
149 out: "\xBF\xFE",
150 }, {
151 mask: 0,
152 in: "a\xBF\xFEb",
153 out: "a\xBF\xFEb",
154 }, {
155 mask: 0,
156 in: "a\xBFξ\xFEb",
157 out: "a\xBFξ\xFEb",
158 }, {
159 mask: EncodeBackSlash,
160 in: "a\xBF\\\xFEb",
161 out: "a\xBF\\xFEb",
162 },
163 } {
164 e := tc.mask
165 t.Run(strconv.FormatInt(int64(i), 10), func(t *testing.T) {
166 got := e.Encode(tc.in)
167 if got != tc.out {
168 t.Errorf("Encode(%q) want %q got %q", tc.in, tc.out, got)
169 }
170 got2 := e.Decode(got)
171 if got2 != tc.in {
172 t.Errorf("Decode(%q) want %q got %q", got, tc.in, got2)
173 }
174 })
175 }
176}
177

Callers

nothing calls this directly

Calls 4

RunMethod · 0.65
EncodeMethod · 0.65
DecodeMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…