forked from johnkerl/miller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unbackslash_test.go
45 lines (40 loc) · 1.16 KB
/
unbackslash_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// ================================================================
// Most Miller tests (thousands of them) are command-line-driven via
// mlr regtest. Here are some cases needing special focus.
// ================================================================
package lib
import (
"testing"
)
type tDataForUnbackslash struct {
input string
expectedOutput string
}
// Note we are here dealing with Go's backslashing conventions.
// At the Miller user-space level this is simply "\t" -> TAB, etc.
var dataForUnbackslash = []tDataForUnbackslash{
{"", ""},
{"abcde", "abcde"},
{`\1`, `\1`},
{`a\tb\tc`, "a\tb\tc"},
{`a\fb\rc`, "a\fb\rc"},
{`a"b"c`, `a"b"c`},
{`a\"b\"c`, `a"b"c`},
{`a\102c`, `aBc`},
{`a\x42c`, `aBc`},
{`[\101\102\103]`, `[ABC]`},
{`[\x44\x45\x46]`, `[DEF]`},
{`\u2766`, `❦`},
{`\U00010877`, `𐡷`},
{`a\u0062c`, `abc`},
}
func TestUnbackslash(t *testing.T) {
for i, entry := range dataForUnbackslash {
actualOutput := UnbackslashStringLiteral(entry.input)
if actualOutput != entry.expectedOutput {
t.Fatalf("case %d input \"%s\" expected \"%s\" got \"%s\"\n",
i, entry.input, entry.expectedOutput, actualOutput,
)
}
}
}