-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
test whether two slices have equal content #275
Comments
Hi @LarsFronius, Before finding the right name for the method there would need to be some clarification on the behaviour:
Sounds like you might be thinking about |
I think this would be out of scope. It's probably better for the developer to sort both arrays and then call |
|
This name seemed like it would be easy to find. Possible alternatives for the name: - ElementsMatch - ContainsSameElements - IsPermutation (C++: http://en.cppreference.com/w/cpp/algorithm/is_permutation) - MatchArray (rspec: http://www.rubydoc.info/github/rspec/rspec-expectations/RSpec/Matchers:match_array) - Other ideas? This implementaiton is O(N^2), while sorting both lists first would be O(nlogn). However, this one doesn't need to copy the lists, so it is simpler and doesn't require additional memory and time for the copies. I realize this was deemed as out of scope stretchr#275 but I decided to give it a shot as I needed it also.
This name seemed like it would be easy to find. Possible alternatives for the name: - ContainsSameElements - IsPermutation (C++: http://en.cppreference.com/w/cpp/algorithm/is_permutation) - MatchArray (rspec: http://www.rubydoc.info/github/rspec/rspec-expectations/RSpec/Matchers:match_array) - EqualSorted - Other ideas? This implementaiton is O(N^2), while sorting both lists first would be O(nlogn). However, this one doesn't need to copy the lists, so it is simpler and doesn't require additional memory and time for the copies. I realize this was deemed as out of scope stretchr#275 but I decided to give it a shot as I needed it also.
An assertion that compares the elements of the slices/arrays disregarding the order, i.e. it checks whether each element in the first array appears the same number of times in it as in the second array. This name seemed like it would be easy to find. Possible alternatives for the name: - ContainsSameElements - IsPermutation (C++: http://en.cppreference.com/w/cpp/algorithm/is_permutation) - MatchArray (rspec: http://www.rubydoc.info/github/rspec/rspec-expectations/RSpec/Matchers:match_array) - EqualSorted - Other ideas? This implementaiton is O(N^2), while sorting both lists first would be O(nlogn). However, this one doesn't need to copy the lists, so it is simpler and doesn't require additional memory and time for the copies. I realize this was deemed as out of scope stretchr#275 but I decided to give it a shot as I needed it also.
An assertion that compares the elements of the slices/arrays disregarding the order, i.e. it checks whether each element in the first slice/array appears the same number of times in it as in the second slice/array. This name seemed like it would be easy to find. Possible alternatives for the name: - ContainsSameElements - IsPermutation (C++: http://en.cppreference.com/w/cpp/algorithm/is_permutation) - MatchArray (rspec: http://www.rubydoc.info/github/rspec/rspec-expectations/RSpec/Matchers:match_array) - EqualSorted - Other ideas? This implementaiton is O(N^2), while sorting both lists first would be O(nlogn). However, this one doesn't need to copy the lists, so it is simpler and doesn't require additional memory and time for the copies. I realize this was deemed as out of scope stretchr#275 but I decided to give it a shot as I needed it also.
An assertion that compares the elements of the slices/arrays disregarding the order, i.e. it checks whether each element in the first slice/array appears the same number of times in it as in the second slice/array. This name seemed like it would be easy to find. Possible alternatives for the name: - ContainsSameElements - IsPermutation (C++: http://en.cppreference.com/w/cpp/algorithm/is_permutation) - MatchArray (rspec: http://www.rubydoc.info/github/rspec/rspec-expectations/RSpec/Matchers:match_array) - EqualSorted - Other ideas? This implementaiton is O(N^2), while sorting both lists first would be O(nlogn). However, this one doesn't need to copy the lists, so it is simpler and doesn't require additional memory and time for the copies. I realize this was deemed as out of scope stretchr#275 but I decided to give it a shot as I needed it also.
An assertion that compares the elements of the slices/arrays disregarding the order, i.e. it checks whether each element in the first slice/array appears the same number of times in it as in the second slice/array. This name seemed like it would be easy to find. Possible alternatives for the name: - ContainsSameElements - IsPermutation (C++: http://en.cppreference.com/w/cpp/algorithm/is_permutation) - MatchArray (rspec: http://www.rubydoc.info/github/rspec/rspec-expectations/RSpec/Matchers:match_array) - EqualSorted - Other ideas? This implementaiton is O(N^2), while sorting both lists first would be O(nlogn). However, this one doesn't need to copy the lists, so it is simpler and doesn't require additional memory and time for the copies. I realize this was deemed as out of scope stretchr#275 but I decided to give it a shot as I needed it also.
An assertion that compares the elements of the slices/arrays disregarding the order, i.e. it checks whether each element in the first slice/array appears the same number of times in it as in the second slice/array. This name seemed like it would be easy to find. Possible alternatives for the name: - ContainsSameElements - IsPermutation (C++: http://en.cppreference.com/w/cpp/algorithm/is_permutation) - MatchArray (rspec: http://www.rubydoc.info/github/rspec/rspec-expectations/RSpec/Matchers:match_array) - EqualSorted - Other ideas? This implementaiton is O(N^2), while sorting both lists first would be O(nlogn). However, this one doesn't need to copy the lists, so it is simpler and doesn't require additional memory and time for the copies. I realize this was deemed as out of scope stretchr#275 but I decided to give it a shot as I needed it also.
An assertion that compares the elements of the slices/arrays disregarding the order, i.e. it checks whether each element in the first slice/array appears the same number of times in it as in the second slice/array. This name seemed like it would be easy to find. Possible alternatives for the name: - ContainsSameElements - IsPermutation (C++: http://en.cppreference.com/w/cpp/algorithm/is_permutation) - MatchArray (rspec: http://www.rubydoc.info/github/rspec/rspec-expectations/RSpec/Matchers:match_array) - EqualSorted - Other ideas? This implementaiton is O(N^2), while sorting both lists first would be O(nlogn). However, this one doesn't need to copy the lists, so it is simpler and doesn't require additional memory and time for the copies. I realize this was deemed as out of scope #275 but I decided to give it a shot as I needed it also.
Now it's the |
@DennisMao is there a way to do the same in |
...
|
@ilovejs if this is an issue with |
I wonder if this inside the scope of testify.
Basically I have two slices of a certain type, which can be of random order and I want to be able to compare, that any of the data of one slice appears on the other slice as well.
A reflect.deepequal does not get the job done, neither does assert.Equal, so is this something to consider as a feature for testify?
e.g.
The text was updated successfully, but these errors were encountered: