|
17 | 17 |
|
18 | 18 | package org.apache.lucene.internal.hppc;
|
19 | 19 |
|
| 20 | +import static org.apache.lucene.internal.hppc.TestIntObjectHashMap.toList; |
| 21 | + |
20 | 22 | import com.carrotsearch.randomizedtesting.RandomizedTest;
|
21 | 23 | import java.util.Arrays;
|
22 | 24 | import java.util.HashMap;
|
23 | 25 | import java.util.HashSet;
|
24 | 26 | import java.util.Random;
|
25 | 27 | import java.util.concurrent.atomic.AtomicInteger;
|
26 | 28 | import org.apache.lucene.tests.util.LuceneTestCase;
|
| 29 | +import org.hamcrest.MatcherAssert; |
| 30 | +import org.hamcrest.Matchers; |
27 | 31 | import org.junit.After;
|
28 | 32 | import org.junit.Test;
|
29 | 33 |
|
@@ -66,13 +70,6 @@ private static void assertSortedListEquals(char[] array, char... elements) {
|
66 | 70 | assertArrayEquals(elements, array);
|
67 | 71 | }
|
68 | 72 |
|
69 |
| - /** Check if the array's content is identical to a given sequence of elements. */ |
70 |
| - private static void assertSortedListEquals(Object[] array, Object... elements) { |
71 |
| - assertEquals(elements.length, array.length); |
72 |
| - Arrays.sort(array); |
73 |
| - assertArrayEquals(elements, array); |
74 |
| - } |
75 |
| - |
76 | 73 | private final int value0 = vcast(0);
|
77 | 74 | private final int value1 = vcast(1);
|
78 | 75 | private final int value2 = vcast(2);
|
@@ -603,13 +600,15 @@ public void testMapValues() {
|
603 | 600 | map.put(key1, value3);
|
604 | 601 | map.put(key2, value2);
|
605 | 602 | map.put(key3, value1);
|
606 |
| - assertSortedListEquals(map.values().toArray(), value1, value2, value3); |
| 603 | + MatcherAssert.assertThat( |
| 604 | + toList(map.values()), Matchers.containsInAnyOrder(value1, value2, value3)); |
607 | 605 |
|
608 | 606 | map.clear();
|
609 | 607 | map.put(key1, value1);
|
610 | 608 | map.put(key2, value2);
|
611 | 609 | map.put(key3, value2);
|
612 |
| - assertSortedListEquals(map.values().toArray(), value1, value2, value2); |
| 610 | + MatcherAssert.assertThat( |
| 611 | + toList(map.values()), Matchers.containsInAnyOrder(value1, value2, value2)); |
613 | 612 | }
|
614 | 613 |
|
615 | 614 | /* */
|
|
0 commit comments