forked from igorwojda/kotlin-coding-challenges
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTests.kt
27 lines (22 loc) · 882 Bytes
/
Tests.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.igorwojda.common.anycallback
import org.amshove.kluent.shouldBeEqualTo
import org.junit.jupiter.api.Test
class Tests {
// Easily switch between a known solution and Challenge code
val functionUnderTest: (list: List<Int>, callback: (Int) -> Boolean)->Boolean = ::anyCallback // or SolutionN::anyCallback
@Test
fun `any callback returns true`() {
val callback: ((Int) -> Boolean) = { it > 3 }
functionUnderTest(listOf(1, 2, 3, 4), callback) shouldBeEqualTo true
}
@Test
fun `any callback returns false`() {
val callback: ((Int) -> Boolean) = { it > 3 }
functionUnderTest(listOf(1, 2, 3), callback) shouldBeEqualTo false
}
@Test
fun `empty list returns false`() {
val callback: ((Int) -> Boolean) = { it > 3 }
functionUnderTest(emptyList(), callback) shouldBeEqualTo false
}
}