diff options
Diffstat (limited to 'shell_test.go')
-rw-r--r-- | shell_test.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/shell_test.go b/shell_test.go index c5564a3..c6ef732 100644 --- a/shell_test.go +++ b/shell_test.go @@ -3,11 +3,11 @@ package shell import ( "fmt" "io" - "io/ioutil" "log" - "reflect" "strings" "testing" + + "github.com/google/go-cmp/cmp" ) func TestQuote(t *testing.T) { @@ -100,8 +100,8 @@ func TestSplit(t *testing.T) { if ok != test.ok { t.Errorf("Split %#q: got valid=%v, want %v", test.in, ok, test.ok) } - if !reflect.DeepEqual(got, test.want) { - t.Errorf("Split %#q: got %+q, want %+q", test.in, got, test.want) + if diff := cmp.Diff(test.want, got); diff != "" { + t.Errorf("Split %#q: (-want, +got)\n%s", test.in, diff) } } } @@ -137,11 +137,11 @@ func TestScannerSplit(t *testing.T) { t.Errorf("Unexpected scan error: %v", s.Err()) } - if !reflect.DeepEqual(got, test.want) { - t.Errorf("Scanner split prefix: got %+q, want %+q", got, test.want) + if diff := cmp.Diff(test.want, got); diff != "" { + t.Errorf("Scanner split prefix: (-want, +got)\n%s", diff) } - if !reflect.DeepEqual(rest, test.rest) { - t.Errorf("Scanner split suffix: got %+q, want %+q", rest, test.rest) + if diff := cmp.Diff(test.rest, rest); diff != "" { + t.Errorf("Scanner split suffix: (-want, +got)\n%s", diff) } } } @@ -167,8 +167,8 @@ func TestRoundTrip(t *testing.T) { if !ok { t.Errorf("Split %+q: should be valid, but is not", s) } - if !reflect.DeepEqual(got, test) { - t.Errorf("Split %+q: got %q, want %q", s, got, test) + if diff := cmp.Diff(test, got); diff != "" { + t.Errorf("Split %+q: (-want, +got)\n%s", s, diff) } } } @@ -194,7 +194,7 @@ func ExampleScanner_Rest() { break } } - rest, err := ioutil.ReadAll(s.Rest()) + rest, err := io.ReadAll(s.Rest()) if err != nil { log.Fatal(err) } |