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 public class StaticBucketMapTest<K, V> extends AbstractIterableMapTest<K, V> {
31
32 public StaticBucketMapTest() {
33 super(StaticBucketMapTest.class.getSimpleName());
34 }
35
36 @Override
37 public String[] ignoredTests() {
38 final String pre = "StaticBucketMapTest.bulkTestMap";
39 final String post = ".testCollectionIteratorFailFast";
40 return new String[] {
41 pre + "EntrySet" + post,
42 pre + "KeySet" + post,
43 pre + "Values" + post
44 };
45 }
46
47
48
49
50 @Override
51 public boolean isFailFastExpected() {
52 return false;
53 }
54
55 @Override
56 public StaticBucketMap<K, V> makeObject() {
57 return new StaticBucketMap<>(30);
58 }
59
60 @Test
61 @SuppressWarnings("unchecked")
62 public void test_containsKey_nullMatchesIncorrectly() {
63 final StaticBucketMap<K, V> map = new StaticBucketMap<>(17);
64 map.put(null, (V) "A");
65 assertTrue(map.containsKey(null));
66
67 for (int i = 'A'; i <= 'Z'; i++) {
68 final String str = String.valueOf((char) i);
69 assertFalse(map.containsKey(str), "String: " + str);
70 }
71 }
72
73 @Test
74 @SuppressWarnings("unchecked")
75 public void test_containsValue_nullMatchesIncorrectly() {
76 final StaticBucketMap<K, V> map = new StaticBucketMap<>(17);
77 map.put((K) "A", null);
78 assertTrue(map.containsValue(null));
79
80 for (int i = 'A'; i <= 'Z'; i++) {
81 final String str = String.valueOf((char) i);
82 assertFalse(map.containsValue(str), "String: " + str);
83 }
84 }
85
86
87 @Test
88 @SuppressWarnings("unchecked")
89 public void test_get_nullMatchesIncorrectly() {
90 final StaticBucketMap<K, V> map = new StaticBucketMap<>(17);
91 map.put(null, (V) "A");
92 assertEquals("A", map.get(null));
93
94 for (int i = 'A'; i <= 'Z'; i++) {
95 final String str = String.valueOf((char) i);
96 assertNull(map.get(str), "String: " + str);
97 }
98 }
99
100 }