Cosmos Nicolaou | 4e213d7 | 2014-10-26 22:21:52 -0700 | [diff] [blame] | 1 | package core |
| 2 | |
| 3 | import "testing" |
| 4 | |
| 5 | func TestCheckArgs(t *testing.T) { |
| 6 | if got, want := checkArgs([]string{}, 1, "<a>"), `wrong # args (got 0, expected 1) expected: "<a>" got: []`; got == nil || got.Error() != want { |
| 7 | t.Errorf("got %v, want %v", got, want) |
| 8 | } |
| 9 | if got, want := checkArgs([]string{}, -1, "<a>"), `wrong # args (got 0, expected >=1) expected: "<a>" got: []`; got == nil || got.Error() != want { |
| 10 | t.Errorf("got %v, want %v", got, want) |
| 11 | } |
| 12 | if got := checkArgs([]string{"a"}, 1, ""); got != nil { |
| 13 | t.Errorf("unexpected error: %s", got) |
| 14 | } |
| 15 | if got := checkArgs([]string{"a"}, -1, ""); got != nil { |
| 16 | t.Errorf("unexpected error: %s", got) |
| 17 | } |
| 18 | if got := checkArgs([]string{"a", "b"}, -1, ""); got != nil { |
| 19 | t.Errorf("unexpected error: %s", got) |
| 20 | } |
| 21 | } |