diff icon indicating copy to clipboard operation
diff copied to clipboard

Bug: Nil slice == empty slices when diffing

Open theFong opened this issue 1 year ago • 0 comments

At the moment, it seems nil/uninitialized slices are == initialized empty list slices.

type testStruct struct {
	A []string
}

func Test_DiffNilList(t *testing.T) {
	p := testStruct{}
	assert.Nil(t, p.A)
	n := testStruct{
		A: []string{},
	}
	assert.NotNil(t, n.A)
	res, err := diff.Diff(p, n)
	if !assert.NoError(t, err) {
		return
	}
	assert.Equal(t, 1, len(res))
}

theFong avatar Nov 08 '23 22:11 theFong