File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -238,6 +238,18 @@ func TestScript(t *testing.T) {
238
238
ts .Check (err )
239
239
}
240
240
},
241
+ // strconv-unquote treats each argument as a go quoted string, unquotes it and prints
242
+ // them, separated by newlines, to stdout
243
+ "strconv-unquote" : func (ts * testscript.TestScript , neg bool , args []string ) {
244
+ if neg {
245
+ ts .Fatalf ("usage: strconv-unquote args..." )
246
+ }
247
+ for _ , quoted := range args {
248
+ s , err := strconv .Unquote (quoted )
249
+ ts .Check (err )
250
+ fmt .Fprintln (ts .Stdout (), s )
251
+ }
252
+ },
241
253
},
242
254
Setup : func (e * testscript.Env ) error {
243
255
// If a testscript loads CUE packages but forgot to set up a cue.mod,
Original file line number Diff line number Diff line change @@ -4,6 +4,12 @@ env CUE_EXPERIMENT=embed=0
4
4
cmp stderr out/noembed
5
5
env CUE_EXPERIMENT=
6
6
7
+ # Create test files for type=binary using strconv-unquote as txtar can only hold UTF8.
8
+ strconv-unquote '"\xef\xbb\xbfHello, 世界"'
9
+ cp stdout test-utf8-bom.binary
10
+ strconv-unquote "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
11
+ cp stdout test-nonutf8.binary
12
+
7
13
exec cue eval
8
14
cmp stdout out/eval
9
15
@@ -39,6 +45,12 @@ f: _ @embed(file="openapi.json", type=openapi)
39
45
40
46
g: _ @embed(file="openapi.json") // test no auto mode!
41
47
48
+ h: _ @embed(file="test-utf8-bom.binary", type=binary)
49
+
50
+ i: _ @embed(file="test-utf8-bom.binary", type=text)
51
+
52
+ j: _ @embed(file="test-nonutf8.binary", type=binary)
53
+
42
54
special: {
43
55
// These are all valid.
44
56
underscoreFile: _ @embed(file="y/_test.json")
@@ -213,6 +225,18 @@ g: {
213
225
}
214
226
}
215
227
}
228
+ h: '''
229
+ Hello, 世界
230
+
231
+ '''
232
+ i: """
233
+ Hello, 世界
234
+
235
+ """
236
+ j: '''
237
+ ��������
238
+
239
+ '''
216
240
special: {
217
241
underscoreFile: {
218
242
z: 45
@@ -273,6 +297,18 @@ g: {
273
297
}
274
298
}
275
299
}
300
+ h: '''
301
+ Hello, 世界
302
+
303
+ '''
304
+ i: """
305
+ Hello, 世界
306
+
307
+ """
308
+ j: '''
309
+ ��������
310
+
311
+ '''
276
312
special: {
277
313
// These are all valid.
278
314
underscoreFile: z: 45
You can’t perform that action at this time.
0 commit comments