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

Commit 0fbe544

Browse files
committed
set関数までのテストを追加
1 parent 7d85a14 commit 0fbe544

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.mapk.fastkfunction.argumentBucket
2+
3+
import com.mapk.fastkfunction.argumentbucket.ArgumentBucket
4+
import com.mapk.fastkfunction.argumentbucket.BucketGenerator
5+
import org.junit.jupiter.api.Assertions.assertEquals
6+
import org.junit.jupiter.api.Assertions.assertNull
7+
import org.junit.jupiter.api.Nested
8+
import org.junit.jupiter.api.Test
9+
10+
private class ArgumentBucketTest {
11+
private val parameters = ::sample.parameters
12+
private val bucket: ArgumentBucket = BucketGenerator(parameters, null).generateBucket()
13+
14+
private fun sample(arg1: Short, arg2: Int, arg3: Long): Long = arg1.toLong() + arg2.toLong() + arg3
15+
16+
@Nested
17+
inner class SetAndGetTest {
18+
val index = 1
19+
val firstValue = 10
20+
val secondValue = 20
21+
22+
@Test
23+
fun byKParameter() {
24+
val param = parameters[index]
25+
26+
assertNull(bucket.set(param, firstValue))
27+
assertEquals(firstValue, bucket[param])
28+
assertEquals(firstValue, bucket.set(param, secondValue))
29+
assertEquals(secondValue, bucket[param])
30+
}
31+
32+
@Test
33+
fun byIndex() {
34+
assertNull(bucket.set(index, firstValue))
35+
assertEquals(firstValue, bucket[index])
36+
assertEquals(firstValue, bucket.set(index, secondValue))
37+
assertEquals(secondValue, bucket[index])
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)