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

Commit b641874

Browse files
committed
setIfAbsent周りのテストを追加
1 parent 57d4f6b commit b641874

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

src/test/kotlin/com/mapk/fastkfunction/argumentBucket/ArgumentBucketTest.kt

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ package com.mapk.fastkfunction.argumentBucket
22

33
import com.mapk.fastkfunction.argumentbucket.ArgumentBucket
44
import com.mapk.fastkfunction.argumentbucket.BucketGenerator
5-
import org.junit.jupiter.api.Assertions.assertEquals
6-
import org.junit.jupiter.api.Assertions.assertNull
5+
import org.junit.jupiter.api.Assertions.*
76
import org.junit.jupiter.api.Nested
87
import org.junit.jupiter.api.Test
98

@@ -37,4 +36,47 @@ private class ArgumentBucketTest {
3736
assertEquals(secondValue, bucket[index])
3837
}
3938
}
39+
40+
@Nested
41+
inner class SetIfAbsentTest {
42+
val index = 1
43+
val firstValue = 10
44+
val secondValue = 20
45+
46+
@Nested
47+
inner class ByKParameter {
48+
val param = parameters[index]
49+
50+
@Test
51+
fun isNull() {
52+
assertNull(bucket.setIfAbsent(param, null))
53+
assertTrue(bucket.containsKey(param))
54+
}
55+
56+
@Test
57+
fun byKParameter() {
58+
assertNull(bucket.setIfAbsent(param, firstValue))
59+
assertEquals(firstValue, bucket[param])
60+
assertEquals(firstValue, bucket.setIfAbsent(param, secondValue))
61+
assertEquals(firstValue, bucket[param])
62+
}
63+
}
64+
65+
@Nested
66+
inner class ByIndex {
67+
@Test
68+
fun isNull() {
69+
assertNull(bucket.setIfAbsent(index, null))
70+
assertTrue(bucket.containsKey(parameters[index]))
71+
}
72+
73+
@Test
74+
fun byKParameter() {
75+
assertNull(bucket.setIfAbsent(index, firstValue))
76+
assertEquals(firstValue, bucket[index])
77+
assertEquals(firstValue, bucket.setIfAbsent(index, secondValue))
78+
assertEquals(firstValue, bucket[index])
79+
}
80+
}
81+
}
4082
}

0 commit comments

Comments
 (0)