Source file
src/runtime/print_quoted_test.go
1
2
3
4
5 package runtime_test
6
7 import (
8 "runtime"
9 "testing"
10 )
11
12 func TestPrintQuoted(t *testing.T) {
13 for _, tbl := range []struct {
14 in, expected string
15 }{
16 {in: "baz", expected: `"baz"`},
17 {in: "foobar", expected: `"foobar"`},
18
19 {in: "baz\n", expected: `"baz\n"`},
20
21 {in: "b\033it", expected: `"b\x1bit"`},
22 {in: "b\000ar", expected: `"b\x00ar"`},
23
24 {in: "\u1234Σ", expected: `"\u1234\u03a3"`},
25
26 {in: "fizz\tle", expected: `"fizz\tle"`},
27 {in: "\U00045678boop", expected: `"\U00045678boop"`},
28
29 {in: "fiz\\zl\re", expected: `"fiz\\zl\re"`},
30 } {
31 t.Run(tbl.in, func(t *testing.T) {
32 out := runtime.DumpPrintQuoted(tbl.in)
33 if out != tbl.expected {
34 t.Errorf("unexpected output for print(escaped(%q));\n got: %s\nwant: %s", tbl.in, out, tbl.expected)
35 }
36 })
37 }
38 }
39
View as plain text