提交 deed1585 authored 作者: Thomas Mueller's avatar Thomas Mueller

spaces instead of tabs

上级 39c7c431
/* /*
* Copyright 2004-2009 H2 Group. Multiple-Licensed under the H2 License, * Copyright 2004-2009 H2 Group. Multiple-Licensed under the H2 License, Version
* Version 1.0, and under the Eclipse Public License, Version 1.0 * 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html). * (http://h2database.com/html/license.html). Initial Developer: H2 Group
* Initial Developer: H2 Group
*/ */
package org.h2.test.unit; package org.h2.test.unit;
import java.util.BitSet; import java.util.BitSet;
import java.util.Random; import java.util.Random;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.util.BitField; import org.h2.util.BitField;
...@@ -85,19 +83,19 @@ public class TestBitField extends TestBase { ...@@ -85,19 +83,19 @@ public class TestBitField extends TestBase {
assertEquals(mask, used.getByte(x)); assertEquals(mask, used.getByte(x));
x += 8; x += 8;
// for (int j = 0; j < 8; j++, x++) { // for (int j = 0; j < 8; j++, x++) {
// if (used.get(x) != ((mask & (1 << j)) != 0)) { // if (used.get(x) != ((mask & (1 << j)) != 0)) {
// throw Message.getInternalError( // throw Message.getInternalError(
// "Redo failure, block: " + x + // "Redo failure, block: " + x +
// " expected in-use bit: " + used.get(x)); // " expected in-use bit: " + used.get(x));
// } // }
// } // }
} else { } else {
used.setByte(x, mask); used.setByte(x, mask);
x += 8; x += 8;
// for (int j = 0; j < 8; j++, x++) { // for (int j = 0; j < 8; j++, x++) {
// if ((mask & (1 << j)) != 0) { // if ((mask & (1 << j)) != 0) {
// used.set(x); // used.set(x);
// } // }
// } // }
} }
} }
...@@ -150,24 +148,24 @@ public class TestBitField extends TestBase { ...@@ -150,24 +148,24 @@ public class TestBitField extends TestBase {
} }
} }
} }
private void testRandomSetRange(){ private void testRandomSetRange() {
BitField bits = new BitField(); BitField bits = new BitField();
BitSet set = new BitSet(); BitSet set = new BitSet();
Random random = new Random(1); Random random = new Random(1);
int maxoff = 500; int maxoff = 500;
int maxlen = 500; int maxlen = 500;
int total = maxoff+maxlen; int total = maxoff + maxlen;
int count = 10000; int count = 10000;
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
int offset = random.nextInt(maxoff); int offset = random.nextInt(maxoff);
int len = random.nextInt(maxlen); int len = random.nextInt(maxlen);
boolean val = random.nextBoolean(); boolean val = random.nextBoolean();
set.set(offset,offset+len,val); set.set(offset, offset + len, val);
bits.setRange(offset,len,val); bits.setRange(offset, len, val);
for(int j=0; j<total; j++){ for (int j = 0; j < total; j++) {
assertEquals(bits.get(j), set.get(j)); assertEquals(bits.get(j), set.get(j));
} }
} }
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论