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

Assert slices equal (including order) #759

Open
ghostsquad opened this issue Apr 29, 2019 · 1 comment
Open

Assert slices equal (including order) #759

ghostsquad opened this issue Apr 29, 2019 · 1 comment

Comments

@ghostsquad
Copy link

Is there any existing method for asserting slices are equal (including order)?

@xordspar0
Copy link
Contributor

The normal assert.Equal method does this. Try it out:

func TestEqual(t *testing.T) {
	a := []int{1, 2}
	b := []int{2, 1}

	assert.Equal(t, a, b)
}

If you want to ignore order, there's a special method for that: assert.ElementsMatch

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

2 participants