@@ -30,15 +30,15 @@ func resetDefaultCharsetsOrder() {
30
30
}
31
31
}
32
32
33
- func TestRemoveBOMIfPresent (t * testing.T ) {
34
- res := RemoveBOMIfPresent ([]byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba })
33
+ func TestMaybeRemoveBOM (t * testing.T ) {
34
+ res := MaybeRemoveBOM ([]byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba }, ConvertOpts { })
35
35
assert .Equal (t , []byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba }, res )
36
36
37
- res = RemoveBOMIfPresent ([]byte {0xef , 0xbb , 0xbf , 0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba })
37
+ res = MaybeRemoveBOM ([]byte {0xef , 0xbb , 0xbf , 0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba }, ConvertOpts { })
38
38
assert .Equal (t , []byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba }, res )
39
39
}
40
40
41
- func TestToUTF8WithErr (t * testing.T ) {
41
+ func TestToUTF8 (t * testing.T ) {
42
42
resetDefaultCharsetsOrder ()
43
43
var res string
44
44
var err error
@@ -47,84 +47,84 @@ func TestToUTF8WithErr(t *testing.T) {
47
47
// locale, so some conversions might behave differently. For that reason, we don't
48
48
// depend on particular conversions but in expected behaviors.
49
49
50
- res , err = ToUTF8WithErr ([]byte {0x41 , 0x42 , 0x43 })
50
+ res , err = ToUTF8 ([]byte {0x41 , 0x42 , 0x43 }, ConvertOpts { })
51
51
assert .NoError (t , err )
52
52
assert .Equal (t , "ABC" , res )
53
53
54
54
// "áéíóú"
55
- res , err = ToUTF8WithErr ([]byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba })
55
+ res , err = ToUTF8 ([]byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba }, ConvertOpts { })
56
56
assert .NoError (t , err )
57
57
assert .Equal (t , []byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba }, []byte (res ))
58
58
59
59
// "áéíóú"
60
- res , err = ToUTF8WithErr ([]byte {
60
+ res , err = ToUTF8 ([]byte {
61
61
0xef , 0xbb , 0xbf , 0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 ,
62
62
0xc3 , 0xba ,
63
- })
63
+ }, ConvertOpts {} )
64
64
assert .NoError (t , err )
65
65
assert .Equal (t , []byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba }, []byte (res ))
66
66
67
- res , err = ToUTF8WithErr ([]byte {
67
+ res , err = ToUTF8 ([]byte {
68
68
0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xED , 0x20 , 0x63 ,
69
69
0xF3 , 0x6D , 0x6F , 0x20 , 0xF1 , 0x6F , 0x73 , 0x41 , 0x41 , 0x41 , 0x2e ,
70
- })
70
+ }, ConvertOpts {} )
71
71
assert .NoError (t , err )
72
72
stringMustStartWith (t , "Hola," , res )
73
73
stringMustEndWith (t , "AAA." , res )
74
74
75
- res , err = ToUTF8WithErr ([]byte {
75
+ res , err = ToUTF8 ([]byte {
76
76
0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xED , 0x20 , 0x63 ,
77
77
0xF3 , 0x6D , 0x6F , 0x20 , 0x07 , 0xA4 , 0x6F , 0x73 , 0x41 , 0x41 , 0x41 , 0x2e ,
78
- })
78
+ }, ConvertOpts {} )
79
79
assert .NoError (t , err )
80
80
stringMustStartWith (t , "Hola," , res )
81
81
stringMustEndWith (t , "AAA." , res )
82
82
83
- res , err = ToUTF8WithErr ([]byte {
83
+ res , err = ToUTF8 ([]byte {
84
84
0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xED , 0x20 , 0x63 ,
85
85
0xF3 , 0x6D , 0x6F , 0x20 , 0x81 , 0xA4 , 0x6F , 0x73 , 0x41 , 0x41 , 0x41 , 0x2e ,
86
- })
86
+ }, ConvertOpts {} )
87
87
assert .NoError (t , err )
88
88
stringMustStartWith (t , "Hola," , res )
89
89
stringMustEndWith (t , "AAA." , res )
90
90
91
91
// Japanese (Shift-JIS)
92
92
// 日属秘ぞしちゅ。
93
- res , err = ToUTF8WithErr ([]byte {
93
+ res , err = ToUTF8 ([]byte {
94
94
0x93 , 0xFA , 0x91 , 0xAE , 0x94 , 0xE9 , 0x82 , 0xBC , 0x82 , 0xB5 , 0x82 ,
95
95
0xBF , 0x82 , 0xE3 , 0x81 , 0x42 ,
96
- })
96
+ }, ConvertOpts {} )
97
97
assert .NoError (t , err )
98
98
assert .Equal (t , []byte {
99
99
0xE6 , 0x97 , 0xA5 , 0xE5 , 0xB1 , 0x9E , 0xE7 , 0xA7 , 0x98 , 0xE3 ,
100
100
0x81 , 0x9E , 0xE3 , 0x81 , 0x97 , 0xE3 , 0x81 , 0xA1 , 0xE3 , 0x82 , 0x85 , 0xE3 , 0x80 , 0x82 ,
101
101
},
102
102
[]byte (res ))
103
103
104
- res , err = ToUTF8WithErr ([]byte {0x00 , 0x00 , 0x00 , 0x00 })
104
+ res , err = ToUTF8 ([]byte {0x00 , 0x00 , 0x00 , 0x00 }, ConvertOpts { })
105
105
assert .NoError (t , err )
106
106
assert .Equal (t , []byte {0x00 , 0x00 , 0x00 , 0x00 }, []byte (res ))
107
107
}
108
108
109
109
func TestToUTF8WithFallback (t * testing.T ) {
110
110
resetDefaultCharsetsOrder ()
111
111
// "ABC"
112
- res := ToUTF8WithFallback ([]byte {0x41 , 0x42 , 0x43 })
112
+ res := ToUTF8WithFallback ([]byte {0x41 , 0x42 , 0x43 }, ConvertOpts {} )
113
113
assert .Equal (t , []byte {0x41 , 0x42 , 0x43 }, res )
114
114
115
115
// "áéíóú"
116
- res = ToUTF8WithFallback ([]byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba })
116
+ res = ToUTF8WithFallback ([]byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba }, ConvertOpts {} )
117
117
assert .Equal (t , []byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba }, res )
118
118
119
119
// UTF8 BOM + "áéíóú"
120
- res = ToUTF8WithFallback ([]byte {0xef , 0xbb , 0xbf , 0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba })
120
+ res = ToUTF8WithFallback ([]byte {0xef , 0xbb , 0xbf , 0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba }, ConvertOpts {} )
121
121
assert .Equal (t , []byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba }, res )
122
122
123
123
// "Hola, así cómo ños"
124
124
res = ToUTF8WithFallback ([]byte {
125
125
0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xED , 0x20 , 0x63 ,
126
126
0xF3 , 0x6D , 0x6F , 0x20 , 0xF1 , 0x6F , 0x73 ,
127
- })
127
+ }, ConvertOpts {} )
128
128
assert .Equal (t , []byte {
129
129
0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xC3 , 0xAD , 0x20 , 0x63 ,
130
130
0xC3 , 0xB3 , 0x6D , 0x6F , 0x20 , 0xC3 , 0xB1 , 0x6F , 0x73 ,
@@ -133,126 +133,65 @@ func TestToUTF8WithFallback(t *testing.T) {
133
133
// "Hola, así cómo "
134
134
minmatch := []byte {0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xC3 , 0xAD , 0x20 , 0x63 , 0xC3 , 0xB3 , 0x6D , 0x6F , 0x20 }
135
135
136
- res = ToUTF8WithFallback ([]byte {0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xED , 0x20 , 0x63 , 0xF3 , 0x6D , 0x6F , 0x20 , 0x07 , 0xA4 , 0x6F , 0x73 })
136
+ res = ToUTF8WithFallback ([]byte {0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xED , 0x20 , 0x63 , 0xF3 , 0x6D , 0x6F , 0x20 , 0x07 , 0xA4 , 0x6F , 0x73 }, ConvertOpts {} )
137
137
// Do not fail for differences in invalid cases, as the library might change the conversion criteria for those
138
138
assert .Equal (t , minmatch , res [0 :len (minmatch )])
139
139
140
- res = ToUTF8WithFallback ([]byte {0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xED , 0x20 , 0x63 , 0xF3 , 0x6D , 0x6F , 0x20 , 0x81 , 0xA4 , 0x6F , 0x73 })
140
+ res = ToUTF8WithFallback ([]byte {0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xED , 0x20 , 0x63 , 0xF3 , 0x6D , 0x6F , 0x20 , 0x81 , 0xA4 , 0x6F , 0x73 }, ConvertOpts {} )
141
141
// Do not fail for differences in invalid cases, as the library might change the conversion criteria for those
142
142
assert .Equal (t , minmatch , res [0 :len (minmatch )])
143
143
144
144
// Japanese (Shift-JIS)
145
145
// "日属秘ぞしちゅ。"
146
- res = ToUTF8WithFallback ([]byte {0x93 , 0xFA , 0x91 , 0xAE , 0x94 , 0xE9 , 0x82 , 0xBC , 0x82 , 0xB5 , 0x82 , 0xBF , 0x82 , 0xE3 , 0x81 , 0x42 })
146
+ res = ToUTF8WithFallback ([]byte {0x93 , 0xFA , 0x91 , 0xAE , 0x94 , 0xE9 , 0x82 , 0xBC , 0x82 , 0xB5 , 0x82 , 0xBF , 0x82 , 0xE3 , 0x81 , 0x42 }, ConvertOpts {} )
147
147
assert .Equal (t , []byte {
148
148
0xE6 , 0x97 , 0xA5 , 0xE5 , 0xB1 , 0x9E , 0xE7 , 0xA7 , 0x98 , 0xE3 ,
149
149
0x81 , 0x9E , 0xE3 , 0x81 , 0x97 , 0xE3 , 0x81 , 0xA1 , 0xE3 , 0x82 , 0x85 , 0xE3 , 0x80 , 0x82 ,
150
150
}, res )
151
151
152
- res = ToUTF8WithFallback ([]byte {0x00 , 0x00 , 0x00 , 0x00 })
152
+ res = ToUTF8WithFallback ([]byte {0x00 , 0x00 , 0x00 , 0x00 }, ConvertOpts {} )
153
153
assert .Equal (t , []byte {0x00 , 0x00 , 0x00 , 0x00 }, res )
154
154
}
155
155
156
- func TestToUTF8 (t * testing.T ) {
157
- resetDefaultCharsetsOrder ()
158
- // Note: golang compiler seems so behave differently depending on the current
159
- // locale, so some conversions might behave differently. For that reason, we don't
160
- // depend on particular conversions but in expected behaviors.
161
-
162
- res := ToUTF8 (string ([]byte {0x41 , 0x42 , 0x43 }))
163
- assert .Equal (t , "ABC" , res )
164
-
165
- // "áéíóú"
166
- res = ToUTF8 (string ([]byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba }))
167
- assert .Equal (t , []byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba }, []byte (res ))
168
-
169
- // BOM + "áéíóú"
170
- res = ToUTF8 (string ([]byte {
171
- 0xef , 0xbb , 0xbf , 0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 ,
172
- 0xc3 , 0xba ,
173
- }))
174
- assert .Equal (t , []byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba }, []byte (res ))
175
-
176
- // Latin1
177
- // Hola, así cómo ños
178
- res = ToUTF8 (string ([]byte {
179
- 0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xED , 0x20 , 0x63 ,
180
- 0xF3 , 0x6D , 0x6F , 0x20 , 0xF1 , 0x6F , 0x73 ,
181
- }))
182
- assert .Equal (t , []byte {
183
- 0x48 , 0x6f , 0x6c , 0x61 , 0x2c , 0x20 , 0x61 , 0x73 , 0xc3 , 0xad , 0x20 , 0x63 ,
184
- 0xc3 , 0xb3 , 0x6d , 0x6f , 0x20 , 0xc3 , 0xb1 , 0x6f , 0x73 ,
185
- }, []byte (res ))
186
-
187
- // Latin1
188
- // Hola, así cómo \x07ños
189
- res = ToUTF8 (string ([]byte {
190
- 0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xED , 0x20 , 0x63 ,
191
- 0xF3 , 0x6D , 0x6F , 0x20 , 0x07 , 0xA4 , 0x6F , 0x73 ,
192
- }))
193
- // Hola,
194
- bytesMustStartWith (t , []byte {0x48 , 0x6F , 0x6C , 0x61 , 0x2C }, []byte (res ))
195
-
196
- // This test FAILS
197
- // res = ToUTF8("Hola, así cómo \x81ños")
198
- // Do not fail for differences in invalid cases, as the library might change the conversion criteria for those
199
- // assert.Regexp(t, "^Hola, así cómo", res)
200
-
201
- // Japanese (Shift-JIS)
202
- // 日属秘ぞしちゅ。
203
- res = ToUTF8 (string ([]byte {
204
- 0x93 , 0xFA , 0x91 , 0xAE , 0x94 , 0xE9 , 0x82 , 0xBC , 0x82 , 0xB5 , 0x82 ,
205
- 0xBF , 0x82 , 0xE3 , 0x81 , 0x42 ,
206
- }))
207
- assert .Equal (t , []byte {
208
- 0xE6 , 0x97 , 0xA5 , 0xE5 , 0xB1 , 0x9E , 0xE7 , 0xA7 , 0x98 , 0xE3 ,
209
- 0x81 , 0x9E , 0xE3 , 0x81 , 0x97 , 0xE3 , 0x81 , 0xA1 , 0xE3 , 0x82 , 0x85 , 0xE3 , 0x80 , 0x82 ,
210
- },
211
- []byte (res ))
212
-
213
- res = ToUTF8 ("\x00 \x00 \x00 \x00 " )
214
- assert .Equal (t , []byte {0x00 , 0x00 , 0x00 , 0x00 }, []byte (res ))
215
- }
216
-
217
156
func TestToUTF8DropErrors (t * testing.T ) {
218
157
resetDefaultCharsetsOrder ()
219
158
// "ABC"
220
- res := ToUTF8DropErrors ([]byte {0x41 , 0x42 , 0x43 })
159
+ res := ToUTF8DropErrors ([]byte {0x41 , 0x42 , 0x43 }, ConvertOpts {} )
221
160
assert .Equal (t , []byte {0x41 , 0x42 , 0x43 }, res )
222
161
223
162
// "áéíóú"
224
- res = ToUTF8DropErrors ([]byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba })
163
+ res = ToUTF8DropErrors ([]byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba }, ConvertOpts {} )
225
164
assert .Equal (t , []byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba }, res )
226
165
227
166
// UTF8 BOM + "áéíóú"
228
- res = ToUTF8DropErrors ([]byte {0xef , 0xbb , 0xbf , 0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba })
167
+ res = ToUTF8DropErrors ([]byte {0xef , 0xbb , 0xbf , 0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba }, ConvertOpts {} )
229
168
assert .Equal (t , []byte {0xc3 , 0xa1 , 0xc3 , 0xa9 , 0xc3 , 0xad , 0xc3 , 0xb3 , 0xc3 , 0xba }, res )
230
169
231
170
// "Hola, así cómo ños"
232
- res = ToUTF8DropErrors ([]byte {0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xED , 0x20 , 0x63 , 0xF3 , 0x6D , 0x6F , 0x20 , 0xF1 , 0x6F , 0x73 })
171
+ res = ToUTF8DropErrors ([]byte {0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xED , 0x20 , 0x63 , 0xF3 , 0x6D , 0x6F , 0x20 , 0xF1 , 0x6F , 0x73 }, ConvertOpts {} )
233
172
assert .Equal (t , []byte {0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 }, res [:8 ])
234
173
assert .Equal (t , []byte {0x73 }, res [len (res )- 1 :])
235
174
236
175
// "Hola, así cómo "
237
176
minmatch := []byte {0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xC3 , 0xAD , 0x20 , 0x63 , 0xC3 , 0xB3 , 0x6D , 0x6F , 0x20 }
238
177
239
- res = ToUTF8DropErrors ([]byte {0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xED , 0x20 , 0x63 , 0xF3 , 0x6D , 0x6F , 0x20 , 0x07 , 0xA4 , 0x6F , 0x73 })
178
+ res = ToUTF8DropErrors ([]byte {0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xED , 0x20 , 0x63 , 0xF3 , 0x6D , 0x6F , 0x20 , 0x07 , 0xA4 , 0x6F , 0x73 }, ConvertOpts {} )
240
179
// Do not fail for differences in invalid cases, as the library might change the conversion criteria for those
241
180
assert .Equal (t , minmatch , res [0 :len (minmatch )])
242
181
243
- res = ToUTF8DropErrors ([]byte {0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xED , 0x20 , 0x63 , 0xF3 , 0x6D , 0x6F , 0x20 , 0x81 , 0xA4 , 0x6F , 0x73 })
182
+ res = ToUTF8DropErrors ([]byte {0x48 , 0x6F , 0x6C , 0x61 , 0x2C , 0x20 , 0x61 , 0x73 , 0xED , 0x20 , 0x63 , 0xF3 , 0x6D , 0x6F , 0x20 , 0x81 , 0xA4 , 0x6F , 0x73 }, ConvertOpts {} )
244
183
// Do not fail for differences in invalid cases, as the library might change the conversion criteria for those
245
184
assert .Equal (t , minmatch , res [0 :len (minmatch )])
246
185
247
186
// Japanese (Shift-JIS)
248
187
// "日属秘ぞしちゅ。"
249
- res = ToUTF8DropErrors ([]byte {0x93 , 0xFA , 0x91 , 0xAE , 0x94 , 0xE9 , 0x82 , 0xBC , 0x82 , 0xB5 , 0x82 , 0xBF , 0x82 , 0xE3 , 0x81 , 0x42 })
188
+ res = ToUTF8DropErrors ([]byte {0x93 , 0xFA , 0x91 , 0xAE , 0x94 , 0xE9 , 0x82 , 0xBC , 0x82 , 0xB5 , 0x82 , 0xBF , 0x82 , 0xE3 , 0x81 , 0x42 }, ConvertOpts {} )
250
189
assert .Equal (t , []byte {
251
190
0xE6 , 0x97 , 0xA5 , 0xE5 , 0xB1 , 0x9E , 0xE7 , 0xA7 , 0x98 , 0xE3 ,
252
191
0x81 , 0x9E , 0xE3 , 0x81 , 0x97 , 0xE3 , 0x81 , 0xA1 , 0xE3 , 0x82 , 0x85 , 0xE3 , 0x80 , 0x82 ,
253
192
}, res )
254
193
255
- res = ToUTF8DropErrors ([]byte {0x00 , 0x00 , 0x00 , 0x00 })
194
+ res = ToUTF8DropErrors ([]byte {0x00 , 0x00 , 0x00 , 0x00 }, ConvertOpts {} )
256
195
assert .Equal (t , []byte {0x00 , 0x00 , 0x00 , 0x00 }, res )
257
196
}
258
197
@@ -302,10 +241,6 @@ func stringMustEndWith(t *testing.T, expected, value string) {
302
241
assert .Equal (t , expected , value [len (value )- len (expected ):])
303
242
}
304
243
305
- func bytesMustStartWith (t * testing.T , expected , value []byte ) {
306
- assert .Equal (t , expected , value [:len (expected )])
307
- }
308
-
309
244
func TestToUTF8WithFallbackReader (t * testing.T ) {
310
245
resetDefaultCharsetsOrder ()
311
246
@@ -317,7 +252,7 @@ func TestToUTF8WithFallbackReader(t *testing.T) {
317
252
}
318
253
input = input [:testLen ]
319
254
input += "// Выключаем"
320
- rd := ToUTF8WithFallbackReader (bytes .NewReader ([]byte (input )))
255
+ rd := ToUTF8WithFallbackReader (bytes .NewReader ([]byte (input )), ConvertOpts {} )
321
256
r , _ := io .ReadAll (rd )
322
257
assert .EqualValuesf (t , input , string (r ), "testing string len=%d" , testLen )
323
258
}
0 commit comments