Guest User

Untitled

a guest
Apr 19th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. object IterableExtSpec : Spek({
  2.  
  3. val list = (0 until 100).toList()
  4. describe("splitAt") {
  5.  
  6. it("asserts when n < 0") {
  7. assertFailsWith<IllegalArgumentException> {
  8. list.splitAt(-2)
  9. }
  10. }
  11.  
  12. it("returns <empty, original> when n = 0") {
  13. assertEquals(listOf<Int>() to list, list.splitAt(0))
  14. }
  15.  
  16. it("returns <original, empty> when n = size") {
  17. assertEquals(list to listOf(), list.splitAt(list.size))
  18. }
  19.  
  20. it("returns <original, empty> when n > size") {
  21. assertEquals(list to listOf(), list.splitAt(list.size + 10))
  22. }
  23.  
  24. it("otherwise splits the list as desired") {
  25. assertEquals(list.take(20) to list.takeLast(list.size - 20), list.splitAt(20))
  26. }
  27. }
  28.  
  29. })
Add Comment
Please, Sign In to add comment