diff options
author | A. Ishikawa <a.ishikawa810@gmail.com> | 2020-05-16 21:11:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-16 21:11:53 -0700 |
commit | aa7c82a3f2093118656c72614a55b7746c369301 (patch) | |
tree | a652ed5c92e1467b9be446bf4a00952c4087d4e4 /cmp/compare_test.go | |
parent | 7e5cb83929c528b29e5a8ac1244eab0436f79bce (diff) | |
download | go-cmp-aa7c82a3f2093118656c72614a55b7746c369301.tar.gz |
Do not use custom format for nil slice (#201)
The custom diff output for slices does not accurately reflect the minute
differences between a nil slice and an empty slice.
Avoid the custom diffing if either value is nil.
Diffstat (limited to 'cmp/compare_test.go')
-rw-r--r-- | cmp/compare_test.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/cmp/compare_test.go b/cmp/compare_test.go index a08df1b..f305b80 100644 --- a/cmp/compare_test.go +++ b/cmp/compare_test.go @@ -905,6 +905,44 @@ using the AllowUnexported option.`, "\n"), }, wantEqual: false, reason: "batched per-line diff desired since string looks like multi-line textual data", + }, { + label: label, + x: MyComposite{ + BytesA: []byte{1, 2, 3}, + BytesB: []MyByte{4, 5, 6}, + BytesC: MyBytes{7, 8, 9}, + IntsA: []int8{-1, -2, -3}, + IntsB: []MyInt{-4, -5, -6}, + IntsC: MyInts{-7, -8, -9}, + UintsA: []uint16{1000, 2000, 3000}, + UintsB: []MyUint{4000, 5000, 6000}, + UintsC: MyUints{7000, 8000, 9000}, + FloatsA: []float32{1.5, 2.5, 3.5}, + FloatsB: []MyFloat{4.5, 5.5, 6.5}, + FloatsC: MyFloats{7.5, 8.5, 9.5}, + }, + y: MyComposite{}, + wantEqual: false, + reason: "batched diffing for non-nil slices and nil slices", + }, { + label: label, + x: MyComposite{ + BytesA: []byte{}, + BytesB: []MyByte{}, + BytesC: MyBytes{}, + IntsA: []int8{}, + IntsB: []MyInt{}, + IntsC: MyInts{}, + UintsA: []uint16{}, + UintsB: []MyUint{}, + UintsC: MyUints{}, + FloatsA: []float32{}, + FloatsB: []MyFloat{}, + FloatsC: MyFloats{}, + }, + y: MyComposite{}, + wantEqual: false, + reason: "batched diffing for empty slices and nil slices", }} } |