Improved TestNilAndEmptyBytes

I forgot that bytes.Equals treats nil and []byte{} as equal.
This commit is contained in:
Greg Holt 2017-08-21 13:45:34 -07:00
parent 85e456ef27
commit b1c8062c18
1 changed files with 3 additions and 1 deletions

View File

@ -1391,7 +1391,9 @@ func TestNilAndEmptyBytes(t *testing.T) {
if err = rows.Err(); err != nil { if err = rows.Err(); err != nil {
t.Fatal(tst.name, err) t.Fatal(tst.name, err)
} }
if !bytes.Equal(scanBytes, tst.expectedBytes) { if tst.expectedBytes == nil && scanBytes != nil {
t.Errorf("%s: %#v != %#v", tst.name, scanBytes, tst.expectedBytes)
} else if !bytes.Equal(scanBytes, tst.expectedBytes) {
t.Errorf("%s: %#v != %#v", tst.name, scanBytes, tst.expectedBytes) t.Errorf("%s: %#v != %#v", tst.name, scanBytes, tst.expectedBytes)
} }
} }