1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.collections4.map;
18
19 import static org.junit.jupiter.api.Assertions.assertEquals;
20 import static org.junit.jupiter.api.Assertions.assertFalse;
21 import static org.junit.jupiter.api.Assertions.assertNull;
22 import static org.junit.jupiter.api.Assertions.assertTrue;
23
24 import org.junit.jupiter.api.Test;
25
26
27
28
29
30
31
32
33 public class StaticBucketMapTest<K, V> extends AbstractIterableMapTest<K, V> {
34
35
36
37
38 @Override
39 public boolean isFailFastExpected() {
40 return false;
41 }
42
43 @Override
44 public StaticBucketMap<K, V> makeObject() {
45 return new StaticBucketMap<>(30);
46 }
47
48 @Test
49 @SuppressWarnings("unchecked")
50 public void test_containsKey_nullMatchesIncorrectly() {
51 final StaticBucketMap<K, V> map = new StaticBucketMap<>(17);
52 map.put(null, (V) "A");
53 assertTrue(map.containsKey(null));
54
55 for (int i = 'A'; i <= 'Z'; i++) {
56 final String str = String.valueOf((char) i);
57 assertFalse(map.containsKey(str), "String: " + str);
58 }
59 }
60
61 @Test
62 @SuppressWarnings("unchecked")
63 public void test_containsValue_nullMatchesIncorrectly() {
64 final StaticBucketMap<K, V> map = new StaticBucketMap<>(17);
65 map.put((K) "A", null);
66 assertTrue(map.containsValue(null));
67
68 for (int i = 'A'; i <= 'Z'; i++) {
69 final String str = String.valueOf((char) i);
70 assertFalse(map.containsValue(str), "String: " + str);
71 }
72 }
73
74
75 @Test
76 @SuppressWarnings("unchecked")
77 public void test_get_nullMatchesIncorrectly() {
78 final StaticBucketMap<K, V> map = new StaticBucketMap<>(17);
79 map.put(null, (V) "A");
80 assertEquals("A", map.get(null));
81
82 for (int i = 'A'; i <= 'Z'; i++) {
83 final String str = String.valueOf((char) i);
84 assertNull(map.get(str), "String: " + str);
85 }
86 }
87
88 }