mirror of
https://github.com/stretchr/testify.git
synced 2025-05-31 11:42:44 +00:00
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 https://github.com/stretchr/testify/issues/275 but I decided to give it a shot as I needed it also.