Skip to content

Bug: Nil slice == empty slices when diffing #106

@theFong

Description

@theFong

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))
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions