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

Add AssertSameElements / AssertElementsMatch (irrelevant order) #33

Closed
Tracked by #27
MarvinJWendt opened this issue Aug 26, 2021 · 4 comments
Closed
Tracked by #27
Assignees
Labels

Comments

@MarvinJWendt
Copy link
Owner

No description provided.

@MarvinJWendt MarvinJWendt mentioned this issue Aug 26, 2021
10 tasks
@MarvinJWendt MarvinJWendt added proposal-accepted proposal New feature or request labels Aug 26, 2021
@MarvinJWendt MarvinJWendt self-assigned this Sep 16, 2021
@github-actions
Copy link

@janisz
Copy link
Contributor

janisz commented Oct 25, 2021

Did I understand this correctly?

// AssertSameElements asserts that two slices contains same elements (including pointers).
// The order is irrelevant.
//
// Example:
//  testza.AssertSameElements(t, []string{"Hello", "World"}, []string{"Hello", "World"})
//  testza.AssertSameElements(t, []int{1,2}, []int{1,2, 3}) // FAILS: 3 appears only in one slice
//  testza.AssertSameElements(t, []int{1,2}, []int{2,1})
//  testza.AssertSameElements(t, []int{1,2}, []int{2,1})
//
//  type A struct {
//	  a string
//  }
//  testza.AssertSameElements(t, []*A{{a: "A"}, {a: "B"}, {a: "C"}}, []*A{{a: "A"}, {a: "B"}, {a: "C"}}) // FAILS: Pointers are different
func AssertSameElements(t testRunner, expected interface{}, actual interface{}, msg ...interface{}) {

}

// AssertElementsMatch asserts that two slices contains same values.
// The order is irrelevant.
//
// Example:
//  testza.AssertElementsMatch(t, []string{"Hello", "World"}, []string{"Hello", "World"})
//  testza.AssertElementsMatch(t, []int{1,2}, []int{1,2, 3}) // FAILS: 3 appears only in one slice
//  testza.AssertElementsMatch(t, []int{1,2}, []int{2,1})
//
//  type A struct {
//	  a string
//  }
//  testza.AssertSameElements(t, []*A{{a: "A"}, {a: "B"}, {a: "C"}}, []*A{{a: "B"}, {a: "C"}, {a: "A"}})
func AssertElementsMatch(t testRunner, expected interface{}, actual interface{}, msg ...interface{}) {

}

@MarvinJWendt
Copy link
Owner Author

MarvinJWendt commented Oct 26, 2021

Hi @janisz, sorry for the miscommunication. I was not sure about the naming, it should be one method.
Other libraries, as testify, named their method ElementsMatch, but I don't really like the name and think that SameElements describes the functionality better. We could have the same name for a better developer experience, or create a similar function with a different name. What do you think would be the better choice?

@MarvinJWendt
Copy link
Owner Author

Published in v0.2.13! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants