(SortedSet<Integer> groundTruth, SortedSet<Integer> testSet, Random rand, int depth)
| 154 | } |
| 155 | |
| 156 | private void testHeadSet(SortedSet<Integer> groundTruth, SortedSet<Integer> testSet, Random rand, int depth) |
| 157 | { |
| 158 | if(groundTruth.isEmpty() || groundTruth.last() - groundTruth.first() <= 0 || groundTruth.last() <= 0)//avoid bad tests |
| 159 | return; |
| 160 | int toElement = rand.nextInt(groundTruth.last()); |
| 161 | |
| 162 | SortedSet<Integer> g_s = groundTruth.headSet(toElement); |
| 163 | SortedSet<Integer> t_s = testSet.headSet(toElement); |
| 164 | |
| 165 | assertSameContent(g_s, t_s); |
| 166 | for(int i = 0; i < 5; i++) |
| 167 | { |
| 168 | int new_val; |
| 169 | if(toElement <= 0) |
| 170 | new_val = Math.min(toElement-1, -rand.nextInt(1000)); |
| 171 | else |
| 172 | new_val = rand.nextInt(toElement); |
| 173 | g_s.add(new_val); |
| 174 | t_s.add(new_val); |
| 175 | } |
| 176 | assertSameContent(g_s, t_s); |
| 177 | assertSameContent(groundTruth, testSet); |
| 178 | |
| 179 | if(depth-- > 0) |
| 180 | testHeadSet(g_s, t_s, rand, depth); |
| 181 | assertSameContent(groundTruth, testSet); |
| 182 | } |
| 183 | |
| 184 | private void testTailSet(SortedSet<Integer> groundTruth, SortedSet<Integer> testSet, Random rand, int depth) |
| 185 | { |
no test coverage detected