(t *testing.T, tcase parseTestCase, gotArgs, gotCmd []string, gotErr error)
| 124 | } |
| 125 | |
| 126 | func checkParseResult(t *testing.T, tcase parseTestCase, gotArgs, gotCmd []string, gotErr error) { |
| 127 | if tcase.Error != "" { |
| 128 | if gotErr == nil { |
| 129 | t.Errorf("expected error and got nil: %#v", tcase) |
| 130 | } |
| 131 | |
| 132 | if gotErr.Error() != tcase.Error { |
| 133 | t.Errorf("error does not match expected error, got: '%s', expected: '%s'", gotErr.Error(), tcase.Error) |
| 134 | } |
| 135 | |
| 136 | return |
| 137 | } |
| 138 | |
| 139 | if gotErr != nil { |
| 140 | t.Errorf("unexpected error: %v on test case: %#v", gotErr, tcase) |
| 141 | return |
| 142 | } |
| 143 | |
| 144 | argsStr, parsedArgsStr := fmt.Sprintf("%s", gotArgs), fmt.Sprintf("%s", tcase.ParsedArgs) |
| 145 | if argsStr != parsedArgsStr { |
| 146 | t.Errorf("args do not match parsed args. got: '%s', expected: '%s'", argsStr, parsedArgsStr) |
| 147 | } |
| 148 | |
| 149 | commandStr, parsedCommandStr := fmt.Sprintf("%s", gotCmd), fmt.Sprintf("%s", tcase.Command) |
| 150 | if commandStr != parsedCommandStr { |
| 151 | t.Errorf("command does not match parsed command. got: '%s', expected: '%s'", commandStr, parsedCommandStr) |
| 152 | } |
| 153 | } |
no test coverage detected