MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / testHeadSet

Method testHeadSet

JSAT/test/jsat/utils/IntSortedSetTest.java:156–182  ·  view source on GitHub ↗
(SortedSet<Integer> groundTruth, SortedSet<Integer> testSet, Random rand, int depth)

Source from the content-addressed store, hash-verified

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 {

Callers 1

testSubSetMethod · 0.95

Calls 6

assertSameContentMethod · 0.95
lastMethod · 0.45
firstMethod · 0.45
headSetMethod · 0.45
minMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected