|
1 | | -import static org.assertj.core.api.Assertions.assertThat; |
| 1 | +import static org.hamcrest.CoreMatchers.*; |
| 2 | +import static org.junit.matchers.JUnitMatchers.*; |
| 3 | +import static org.junit.Assert.*; |
2 | 4 |
|
3 | | -import java.util.Arrays; |
4 | | -import java.util.List; |
5 | | -import org.junit.Test; |
| 5 | +import java.util.*; |
| 6 | +import org.junit.*; |
6 | 7 |
|
7 | 8 | public class AnagramTest { |
8 | 9 |
|
9 | 10 | @Test |
10 | 11 | public void testNoMatches() { |
11 | 12 | Anagram detector = new Anagram("diaper"); |
12 | | - assertThat(detector.match(Arrays.asList("hello", "world", "zombies", "pants"))).isEmpty(); |
| 13 | + assertTrue(detector.match(Arrays.asList("hello", "world", "zombies", "pants")).isEmpty()); |
13 | 14 | } |
14 | 15 |
|
15 | 16 | @Test |
16 | 17 | public void testSimpleAnagram() { |
17 | 18 | Anagram detector = new Anagram("ant"); |
18 | 19 | List<String> anagram = detector.match(Arrays.asList("tan", "stand", "at")); |
19 | | - assertThat(anagram).containsExactly("tan"); |
| 20 | + assertThat(anagram, hasItems("tan")); |
20 | 21 | } |
21 | 22 |
|
22 | 23 | @Test |
23 | 24 | public void testDetectMultipleAnagrams() { |
24 | 25 | Anagram detector = new Anagram("master"); |
25 | 26 | List<String> anagrams = detector.match(Arrays.asList("stream", "pigeon", "maters")); |
26 | | - assertThat(anagrams).contains("maters", "stream"); |
| 27 | + assertThat(anagrams, hasItems("maters", "stream")); |
27 | 28 | } |
28 | 29 |
|
29 | 30 | @Test |
30 | 31 | public void testDoesNotConfuseDifferentDuplicates() { |
31 | 32 | Anagram detector = new Anagram("galea"); |
32 | 33 | List<String> anagrams = detector.match(Arrays.asList("eagle")); |
33 | | - assertThat(anagrams).isEmpty(); |
| 34 | + assertTrue(anagrams.isEmpty()); |
34 | 35 | } |
35 | 36 |
|
36 | 37 | @Test |
37 | 38 | public void testIdenticalWordIsNotAnagram() { |
38 | 39 | Anagram detector = new Anagram("corn"); |
39 | 40 | List<String> anagrams = detector.match(Arrays.asList("corn", "dark", "Corn", "rank", "CORN", "cron", "park")); |
40 | | - assertThat(anagrams).containsExactly("cron"); |
| 41 | + assertEquals(anagrams, Arrays.asList("cron")); |
41 | 42 | } |
42 | 43 |
|
43 | 44 | @Test |
44 | 45 | public void testEliminateAnagramsWithSameChecksum() { |
45 | 46 | Anagram detector = new Anagram("mass"); |
46 | | - assertThat(detector.match(Arrays.asList("last")).isEmpty()); |
| 47 | + assertTrue(detector.match(Arrays.asList("last")).isEmpty()); |
47 | 48 | } |
48 | 49 |
|
49 | 50 | @Test |
50 | 51 | public void testEliminateAnagramSubsets() { |
51 | 52 | Anagram detector = new Anagram("good"); |
52 | | - assertThat(detector.match(Arrays.asList("dog", "goody"))).isEmpty(); |
| 53 | + assertTrue(detector.match(Arrays.asList("dog", "goody")).isEmpty()); |
53 | 54 | } |
54 | 55 |
|
55 | 56 | @Test |
56 | 57 | public void testDetectAnagrams() { |
57 | 58 | Anagram detector = new Anagram("listen"); |
58 | 59 | List<String> anagrams = detector.match(Arrays.asList("enlists", "google", "inlets", "banana")); |
59 | | - assertThat(anagrams).contains("inlets"); |
| 60 | + assertThat(anagrams, hasItems("inlets")); |
60 | 61 | } |
61 | 62 |
|
62 | 63 | @Test |
63 | 64 | public void testMultipleAnagrams() { |
64 | 65 | Anagram detector = new Anagram("allergy"); |
65 | 66 | List<String> anagrams = detector.match(Arrays.asList("gallery", "ballerina", "regally", "clergy", "largely", "leading")); |
66 | | - assertThat(anagrams).contains("gallery", "largely", "regally"); |
| 67 | + assertThat(anagrams, hasItems("gallery", "largely", "regally")); |
67 | 68 | } |
68 | 69 |
|
69 | 70 | @Test |
70 | 71 | public void testAnagramsAreCaseInsensitive() { |
71 | 72 | Anagram detector = new Anagram("Orchestra"); |
72 | 73 | List<String> anagrams = detector.match(Arrays.asList("cashregister", "Carthorse", "radishes")); |
73 | | - assertThat(anagrams).contains("Carthorse"); |
| 74 | + assertThat(anagrams, hasItems("Carthorse")); |
74 | 75 | } |
75 | 76 |
|
76 | 77 | } |
0 commit comments