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

Sorted Collections assertion #167

Closed
sandjelkovic opened this issue Oct 24, 2019 · 1 comment · Fixed by #173
Closed

Sorted Collections assertion #167

sandjelkovic opened this issue Oct 24, 2019 · 1 comment · Fixed by #173

Comments

@sandjelkovic
Copy link

sandjelkovic commented Oct 24, 2019

It would be great to have an assertion which can check if the Collection is already sorted. The assertion would also accept a Comparator instance to verify with. Similar (or same) as AssertJ

It would be something along these lines:

list shouldBeSortedAccordingTo Comparator.comparingInt { it.position }

or

list shouldBeSortedBy Comparator.comparingInt { it.position }

This could then be chained to a structure like this

list.shouldNotBeEmpty()
.shouldHaveSize(10)
.shouldBeSortedAccordingTo(Comparator.comparing<Slot, Int> { it.position })
@MarkusAmshove
Copy link
Owner

This is a nice idea, I like it. Would you be willing to open a PR? :-)

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

Successfully merging a pull request may close this issue.

2 participants