Skip to content
This repository was archived by the owner on Jan 20, 2023. It is now read-only.

Commit 2c597f0

Browse files
committed
変なreceiverを渡した時のテストを追加
1 parent f6da2e7 commit 2c597f0

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/test/kotlin/com/mapk/fastkfunction/FastKFunctionTest.kt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,25 @@ private class FastKFunctionTest {
6767
@Nested
6868
inner class TopLevelFunctionOfTest {
6969
@Nested
70+
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
7071
inner class KindIsExtensionFunction {
7172
val function: KFunction<Unit> = String::topLevelExtensionFunc
7273
val parameters = function.parameters
7374
val javaMethod = function.javaMethod!!
7475

75-
@Test
76-
fun nullInstanceTest() {
76+
@ParameterizedTest
77+
@MethodSource("illegalReceiverProvider")
78+
fun illegalReceiverTest(receiver: Any?) {
7779
assertThrows<IllegalArgumentException> {
78-
FastKFunction.topLevelFunctionOf(function, null, parameters, javaMethod)
80+
FastKFunction.topLevelFunctionOf(function, receiver, parameters, javaMethod)
7981
}
8082
}
8183

84+
fun illegalReceiverProvider(): Stream<Arguments> = Stream.of(
85+
Arguments.of(null),
86+
Arguments.of(0)
87+
)
88+
8289
@Test
8390
fun isCorrect() {
8491
val result = assertDoesNotThrow {
@@ -95,6 +102,13 @@ private class FastKFunctionTest {
95102
val parameters = function.parameters
96103
val javaMethod = function.javaMethod!!
97104

105+
@Test
106+
fun withIllegalReceiverTest() {
107+
assertThrows<IllegalArgumentException> {
108+
FastKFunction.topLevelFunctionOf(function, 0, parameters, javaMethod)
109+
}
110+
}
111+
98112
@Test
99113
fun withInstanceTest() {
100114
val result = assertDoesNotThrow {

0 commit comments

Comments
 (0)