diff options
author | M. J. Fromberger <michael.j.fromberger@gmail.com> | 2020-08-27 17:12:59 -0700 |
---|---|---|
committer | M. J. Fromberger <michael.j.fromberger@gmail.com> | 2020-08-27 17:53:36 -0700 |
commit | 5e021ffb4b6f1ee50f73535559a3ed6227187c07 (patch) | |
tree | 1a8a888311bc56f44fd64de89d2c66e9f0e75c47 | |
parent | 18d6290bf107bf085609169659f5f889d5cb6ac7 (diff) | |
download | go-creachadair-shell-5e021ffb4b6f1ee50f73535559a3ed6227187c07.tar.gz |
Replace reflect.DeepEqual with cmp.Diff.
-rw-r--r-- | go.mod | 2 | ||||
-rw-r--r-- | go.sum | 4 | ||||
-rw-r--r-- | shell_test.go | 19 |
3 files changed, 16 insertions, 9 deletions
@@ -1,3 +1,5 @@ module bitbucket.org/creachadair/shell go 1.12 + +require github.com/google/go-cmp v0.5.2 @@ -0,0 +1,4 @@ +github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/shell_test.go b/shell_test.go index c5564a3..38ee1a8 100644 --- a/shell_test.go +++ b/shell_test.go @@ -5,9 +5,10 @@ import ( "io" "io/ioutil" "log" - "reflect" "strings" "testing" + + "github.com/google/go-cmp/cmp" ) func TestQuote(t *testing.T) { @@ -100,8 +101,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 +138,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 +168,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) } } } |