Skip to content

Commit

Permalink
Add test to check that sample() returns read-only collection
Browse files Browse the repository at this point in the history
  • Loading branch information
gstamatelat committed Jul 31, 2021
1 parent 50d5383 commit 3170054
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test/java/gr/james/sampling/RandomSamplingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,17 @@ public void sampleView() {
Assert.assertTrue(RandomSamplingUtils.samplesEquals(sample, new HashSet<>(Arrays.asList(1, 2))));
}

/**
* Check that the sample() method returns read-only collection.
*/
@Test(expected = UnsupportedOperationException.class)
public void readOnlySample() {
final RandomSampling<Integer> rs = impl.get();
rs.feed(1);
rs.feed(2);
rs.sample().add(3);
}

/**
* {@link RandomSampling#streamSize()} correctness.
*/
Expand Down

0 comments on commit 3170054

Please sign in to comment.