提交 07063c2c authored 作者: buckyballs's avatar buckyballs

New Test for BitField.setRange

上级 4320d3b2
......@@ -32,6 +32,7 @@ public class TestBitField extends TestBase {
testByteOperations();
testRandom();
testGetSet();
testRandomSetRange();
}
private void testNextSetBit() {
......@@ -149,4 +150,24 @@ public class TestBitField extends TestBase {
}
}
}
private void testRandomSetRange(){
BitField bits = new BitField();
BitSet set = new BitSet();
Random random = new Random(1);
int maxoff = 500;
int maxlen = 500;
int total = maxoff+maxlen;
int count = 10000;
for (int i = 0; i < count; i++) {
int offset = random.nextInt(maxoff);
int len = random.nextInt(maxlen);
boolean val = random.nextBoolean();
set.set(offset,offset+len,val);
bits.setRange(offset,len,val);
for(int j=0; j<total; j++){
assertEquals(bits.get(j), set.get(j));
}
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论