Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #517 from LordRaydenMK/master
Browse files Browse the repository at this point in the history
Tests for moveUp and moveDown
  • Loading branch information
Edvin Syse authored Oct 29, 2017
2 parents d8d1c7e + e97f53f commit 4382e9e
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/test/kotlin/tornadofx/tests/CollectionsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package tornadofx.tests
import org.junit.Test
import tornadofx.*
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertTrue

class CollectionsTest {

Expand Down Expand Up @@ -127,4 +129,44 @@ class CollectionsTest {
assert(e is IllegalStateException)
}
}

@Test
fun testMoveUpWithValidItem() {
val list = mutableListOf(0, 1, 2, 3, 4)

val result = list.moveUp(2)

assertTrue(result)
assertEquals(listOf(0, 2, 1, 3, 4), list)
}

@Test
fun testMoveUpWithInvalidItem() {
val list = mutableListOf(0, 1, 2, 3, 4)

val result = list.moveUp(10)

assertFalse(result)
assertEquals(listOf(0, 1, 2, 3, 4), list)
}

@Test
fun testMoveDownWithValidItem() {
val list = mutableListOf(0, 1, 2, 3, 4)

val result = list.moveDown(2)

assertTrue(result)
assertEquals(listOf(0, 1, 3, 2, 4), list)
}

@Test
fun testMoveDownWithInvalidItem() {
val list = mutableListOf(0, 1, 2, 3, 4)

val result = list.moveDown(10)

assertFalse(result)
assertEquals(listOf(0, 1, 2, 3, 4), list)
}
}

0 comments on commit 4382e9e

Please sign in to comment.