...
1
2
3
4
5
6
7
8
9
10
11
12
13 package mango
14
15 import (
16 "testing"
17
18 "github.com/google/go-cmp/cmp"
19 )
20
21 func TestSplitKeys(t *testing.T) {
22 tests := []struct {
23 input string
24 want []string
25 }{
26 {
27 input: "foo.bar.baz",
28 want: []string{"foo", "bar", "baz"},
29 },
30 {
31 input: "foo",
32 want: []string{"foo"},
33 },
34 {
35 input: "",
36 want: []string{""},
37 },
38 {
39 input: "foo\\.bar",
40 want: []string{"foo.bar"},
41 },
42 {
43 input: "foo\\\\.bar",
44 want: []string{"foo\\", "bar"},
45 },
46 {
47 input: "foo\\",
48 want: []string{"foo\\"},
49 },
50 {
51 input: "foo.",
52 want: []string{"foo", ""},
53 },
54 }
55
56 for _, tt := range tests {
57 t.Run(tt.input, func(t *testing.T) {
58 got := SplitKeys(tt.input)
59 if d := cmp.Diff(tt.want, got); d != "" {
60 t.Errorf("unexpected keys (-want, +got): %s", d)
61 }
62 })
63 }
64 }
65
View as plain text