|
| 1 | +import org.junit.Ignore; |
| 2 | +import org.junit.Test; |
| 3 | + |
| 4 | +import java.util.List; |
| 5 | + |
| 6 | +import static java.util.Arrays.asList; |
| 7 | +import static java.util.Collections.emptyList; |
| 8 | +import static org.junit.Assert.assertEquals; |
| 9 | + |
| 10 | +public class RelationshipComputerTest { |
| 11 | + |
| 12 | + @Test |
| 13 | + public void testThatTwoEmptyListsAreConsideredEqual() { |
| 14 | + Relationship computedRelationship = new RelationshipComputer<>().computeRelationship( |
| 15 | + emptyList(), |
| 16 | + emptyList()); |
| 17 | + |
| 18 | + assertEquals(Relationship.EQUAL, computedRelationship); |
| 19 | + } |
| 20 | + |
| 21 | + @Ignore |
| 22 | + @Test |
| 23 | + public void testEmptyListIsSublistOfNonEmptyList() { |
| 24 | + Relationship relationship = new RelationshipComputer<>().computeRelationship( |
| 25 | + emptyList(), |
| 26 | + asList(1, 2, 3)); |
| 27 | + |
| 28 | + assertEquals(Relationship.SUBLIST, relationship); |
| 29 | + } |
| 30 | + |
| 31 | + @Ignore |
| 32 | + @Test |
| 33 | + public void testNonEmptyListIsSuperlistOfEmptyList() { |
| 34 | + Relationship relationship = new RelationshipComputer<>().computeRelationship( |
| 35 | + asList('1', '2', '3'), |
| 36 | + emptyList()); |
| 37 | + |
| 38 | + assertEquals(Relationship.SUPERLIST, relationship); |
| 39 | + } |
| 40 | + |
| 41 | + @Ignore |
| 42 | + @Test |
| 43 | + public void testListIsEqualToItself() { |
| 44 | + List<String> anyList = asList("1", "2", "3"); |
| 45 | + |
| 46 | + Relationship relationship = new RelationshipComputer<String>().computeRelationship( |
| 47 | + anyList, |
| 48 | + anyList); |
| 49 | + |
| 50 | + assertEquals(Relationship.EQUAL, relationship); |
| 51 | + } |
| 52 | + |
| 53 | + @Ignore |
| 54 | + @Test |
| 55 | + public void testDifferentListsOfTheSameLengthAreUnequal() { |
| 56 | + Relationship relationship = new RelationshipComputer<>().computeRelationship( |
| 57 | + asList(1, 2, 3), |
| 58 | + asList(2, 3, 4)); |
| 59 | + |
| 60 | + assertEquals(Relationship.UNEQUAL, relationship); |
| 61 | + } |
| 62 | + |
| 63 | + @Ignore |
| 64 | + @Test |
| 65 | + public void testSublistCheckDoesNotAbortAfterFalseStart() { |
| 66 | + Relationship relationship = new RelationshipComputer<>().computeRelationship( |
| 67 | + asList('1', '2', '5'), |
| 68 | + asList('0', '1', '2', '3', '1', '2', '5', '6')); |
| 69 | + |
| 70 | + assertEquals(Relationship.SUBLIST, relationship); |
| 71 | + } |
| 72 | + |
| 73 | + @Ignore |
| 74 | + @Test |
| 75 | + public void testSublistCheckHandlesExtraneousRepeatsOfFirstEntry() { |
| 76 | + Relationship relationship = new RelationshipComputer<>().computeRelationship( |
| 77 | + asList("1", "1", "2"), |
| 78 | + asList("0", "1", "1", "1", "2", "1", "2")); |
| 79 | + |
| 80 | + assertEquals(Relationship.SUBLIST, relationship); |
| 81 | + } |
| 82 | + |
| 83 | + @Ignore |
| 84 | + @Test |
| 85 | + public void testSublistAtStart() { |
| 86 | + Relationship relationship = new RelationshipComputer<>().computeRelationship( |
| 87 | + asList(0, 1, 2), |
| 88 | + asList(0, 1, 2, 3, 4, 5)); |
| 89 | + |
| 90 | + assertEquals(Relationship.SUBLIST, relationship); |
| 91 | + } |
| 92 | + |
| 93 | + @Ignore |
| 94 | + @Test |
| 95 | + public void testSublistInMiddle() { |
| 96 | + Relationship relationship = new RelationshipComputer<>().computeRelationship( |
| 97 | + asList('2', '3', '4'), |
| 98 | + asList('0', '1', '2', '3', '4', '5')); |
| 99 | + |
| 100 | + assertEquals(Relationship.SUBLIST, relationship); |
| 101 | + } |
| 102 | + |
| 103 | + @Ignore |
| 104 | + @Test |
| 105 | + public void testSublistAtEnd() { |
| 106 | + Relationship relationship = new RelationshipComputer<>().computeRelationship( |
| 107 | + asList("3", "4", "5"), |
| 108 | + asList("0", "1", "2", "3", "4", "5")); |
| 109 | + |
| 110 | + assertEquals(Relationship.SUBLIST, relationship); |
| 111 | + } |
| 112 | + |
| 113 | + @Ignore |
| 114 | + @Test |
| 115 | + public void testAtStartOfSuperlist() { |
| 116 | + Relationship relationship = new RelationshipComputer<>().computeRelationship( |
| 117 | + asList(0, 1, 2, 3, 4, 5), |
| 118 | + asList(0, 1, 2)); |
| 119 | + |
| 120 | + assertEquals(Relationship.SUPERLIST, relationship); |
| 121 | + } |
| 122 | + |
| 123 | + @Ignore |
| 124 | + @Test |
| 125 | + public void testInMiddleOfSuperlist() { |
| 126 | + Relationship relationship = new RelationshipComputer<>().computeRelationship( |
| 127 | + asList('0', '1', '2', '3', '4', '5'), |
| 128 | + asList('2', '3')); |
| 129 | + |
| 130 | + assertEquals(Relationship.SUPERLIST, relationship); |
| 131 | + } |
| 132 | + |
| 133 | + @Ignore |
| 134 | + @Test |
| 135 | + public void testAtEndOfSuperlist() { |
| 136 | + Relationship relationship = new RelationshipComputer<>().computeRelationship( |
| 137 | + asList("0", "1", "2", "3", "4", "5"), |
| 138 | + asList("3", "4", "5")); |
| 139 | + |
| 140 | + assertEquals(Relationship.SUPERLIST, relationship); |
| 141 | + } |
| 142 | + |
| 143 | + @Ignore |
| 144 | + @Test |
| 145 | + public void testFirstListMissingElementFromSecondList() { |
| 146 | + Relationship relationship = new RelationshipComputer<>().computeRelationship( |
| 147 | + asList(1, 3), |
| 148 | + asList(1, 2, 3)); |
| 149 | + |
| 150 | + assertEquals(Relationship.UNEQUAL, relationship); |
| 151 | + } |
| 152 | + |
| 153 | + @Ignore |
| 154 | + @Test |
| 155 | + public void testSecondListMissingElementFromFirstList() { |
| 156 | + Relationship relationship = new RelationshipComputer<>().computeRelationship( |
| 157 | + asList('1', '2', '3'), |
| 158 | + asList('1', '3')); |
| 159 | + |
| 160 | + assertEquals(Relationship.UNEQUAL, relationship); |
| 161 | + } |
| 162 | + |
| 163 | + @Ignore |
| 164 | + @Test |
| 165 | + public void testThatListOrderingIsAccountedFor() { |
| 166 | + Relationship relationship = new RelationshipComputer<>().computeRelationship( |
| 167 | + asList("1", "2", "3"), |
| 168 | + asList("3", "2", "1")); |
| 169 | + |
| 170 | + assertEquals(Relationship.UNEQUAL, relationship); |
| 171 | + } |
| 172 | + |
| 173 | + @Ignore |
| 174 | + @Test |
| 175 | + public void testThatListsWithSameDigitsButDifferentNumbersAreUnequal() { |
| 176 | + Relationship relationship = new RelationshipComputer<>().computeRelationship( |
| 177 | + asList(1, 0, 1), |
| 178 | + asList(10, 1)); |
| 179 | + |
| 180 | + assertEquals(Relationship.UNEQUAL, relationship); |
| 181 | + } |
| 182 | + |
| 183 | +} |
0 commit comments