@@ -2,8 +2,7 @@ package com.mapk.fastkfunction.argumentBucket
2
2
3
3
import com.mapk.fastkfunction.argumentbucket.ArgumentBucket
4
4
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.*
7
6
import org.junit.jupiter.api.Nested
8
7
import org.junit.jupiter.api.Test
9
8
@@ -37,4 +36,47 @@ private class ArgumentBucketTest {
37
36
assertEquals(secondValue, bucket[index])
38
37
}
39
38
}
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
+ }
40
82
}
0 commit comments