Shinichiro Hamaji | 0439a3e | 2015-04-01 02:01:05 +0900 | [diff] [blame^] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "reflect" |
| 5 | "testing" |
| 6 | ) |
| 7 | |
| 8 | func TestRuleParser(t *testing.T) { |
| 9 | for _, tc := range []struct { |
| 10 | in string |
| 11 | want Rule |
| 12 | } { |
| 13 | { |
| 14 | in: "foo: bar", |
| 15 | want: Rule{ |
| 16 | outputs: []string{"foo"}, |
| 17 | inputs: []string{"bar"}, |
| 18 | }, |
| 19 | }, |
| 20 | { |
| 21 | in: "foo: bar baz", |
| 22 | want: Rule{ |
| 23 | outputs: []string{"foo"}, |
| 24 | inputs: []string{"bar", "baz"}, |
| 25 | }, |
| 26 | }, |
| 27 | } { |
| 28 | got := &Rule{} |
| 29 | got.parse(tc.in) |
| 30 | if !reflect.DeepEqual(tc.want, *got) { |
| 31 | t.Errorf(`r.parse(%q)=%q, want %q`, tc.in, tc.want, *got) |
| 32 | } |
| 33 | } |
| 34 | } |