Export to GitHub

fest - issue #315

add isOrdered assertion to arrays/collections


Posted on Aug 25, 2009 by Helpful Ox

I would like to have a method on array and collection Assert classes that asserts that the object's items are ordered.

For primitive arrays, the ordering is natural. I would assume a signature like FloatArrayAssert.isOrdered(). For Object arrays and collections, I might do something like ObjectArrayAssert.isOrdered() that uses the natural ordering and maybe another method ObjectArrayAssert.isOrdered(Comparator) so that you can specify how to determine it is ordered. One question is what to do in ObjectArrayAssert.isOrdered() when one of the the objects does not implement Comparable. I would probably throw the assertion in that case.

Status: New