Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
theFong opened this issue Nov 8, 2023 · 0 comments
Open

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

theFong opened this issue Nov 8, 2023 · 0 comments

Comments

@theFong
Copy link

theFong commented Nov 8, 2023

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))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant