1
2
3
4
5 package godebug
6
7 import "testing"
8
9 func TestGet(t *testing.T) {
10 tests := []struct {
11 godebug string
12 key string
13 want string
14 }{
15 {"", "", ""},
16 {"", "foo", ""},
17 {"foo=bar", "foo", "bar"},
18 {"foo=bar,after=x", "foo", "bar"},
19 {"before=x,foo=bar,after=x", "foo", "bar"},
20 {"before=x,foo=bar", "foo", "bar"},
21 {",,,foo=bar,,,", "foo", "bar"},
22 {"foodecoy=wrong,foo=bar", "foo", "bar"},
23 {"foo=", "foo", ""},
24 {"foo", "foo", ""},
25 {",foo", "foo", ""},
26 {"foo=bar,baz", "loooooooong", ""},
27 }
28 for _, tt := range tests {
29 got := get(tt.godebug, tt.key)
30 if got != tt.want {
31 t.Errorf("get(%q, %q) = %q; want %q", tt.godebug, tt.key, got, tt.want)
32 }
33 }
34 }
35
View as plain text