Skip to content

Commit

Permalink
Add test RandomSamplingTest.firstElements
Browse files Browse the repository at this point in the history
  • Loading branch information
gstamatelat committed Jun 29, 2018
1 parent ebdee65 commit 8363e27
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/test/java/gr/james/sampling/RandomSamplingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,18 @@ public void streamSize() {
Assert.assertEquals(size, rs.streamSize());
}

/**
* The first elements must go directly in the sample.
*/
@Test
public void firstElements() {
final RandomSampling<Integer> rs = impl.get();
final Set<Integer> feeded = new HashSet<>();
for (int i = 0; i < rs.sampleSize(); i++) {
rs.feed(i);
feeded.add(i);
Assert.assertTrue(RandomSamplingUtils.samplesEquals(rs.sample(), feeded));
}
}

}

0 comments on commit 8363e27

Please sign in to comment.