Пример #1
0
  public void shouldReturnUnitializedValues() {
    CircularBitSet bs = new CircularBitSet(100, null);
    for (int i = 0; i < 100; i++) {
      assertEquals(bs.setNext(true), -1);
    }

    assertEquals(bs.setNext(true), 1);
    assertEquals(bs.setNext(true), 1);
  }
Пример #2
0
  public void testRatios() {
    CircularBitSet bs = new CircularBitSet(100, null);

    for (int i = 0; i < 50; i++) bs.setNext(i % 3 == 0);
    assertEquals(bs.positiveRatio(), .34);
    assertEquals(bs.negativeRatio(), .66);

    for (int i = 0; i < 100; i++) bs.setNext(true);
    assertEquals(bs.positiveRatio(), 1.0);
    assertEquals(bs.negativeRatio(), 0.0);
  }
Пример #3
0
 private void setBits(CircularBitSet bs, boolean value, int count) {
   for (int i = 0; i < count; i++) bs.setNext(value);
 }