Skip to content

Commit fc48350

Browse files
authored
Unit test output (#45)
1 parent 6eaf712 commit fc48350

16 files changed

+263
-235
lines changed

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1010

1111
## [2.1.4 - Unreleased]
1212

13+
### Fixed
1314
- Fixed tree corruption after remove() in QT2. [#40](https://github.com/tzaeschke/tinspin-indexes/issues/40)
1415
- Fixed tree consistency (single-entry leaf after remove)
1516
- Fixed tree consistency (nValues) -> verify
1617
- Fixed bug in qt2.contains()
1718
- Fixed QT2 inconsistency after root resizing after insert(). [#42](https://github.com/tzaeschke/tinspin-indexes/issues/42)
18-
Essentially, we enforce all radii and the center of the root to be a power of two.
19-
This should immensely reduce and problems with precision errors.
19+
Essentially, we force all radii and the center of the root to be powers of two.
20+
This should immensely reduce precision problems.
21+
- Removed unnecessary JUnit test console output. [#45](https://github.com/tzaeschke/tinspin-indexes/pull/45)
2022

2123
## [2.1.3] - 2023-11-19
2224

src/main/java/org/tinspin/index/critbit/Examples.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
*/
2929
public class Examples {
3030

31+
public static boolean PRINT = true;
32+
3133
public static void main(String[] args) {
3234
ex1D_32();
3335
ex1D_float();
@@ -123,6 +125,8 @@ private static void ex4D() {
123125
}
124126

125127
private static void log(String msg) {
126-
System.out.println(msg);
128+
if (PRINT) {
129+
System.out.println(msg);
130+
}
127131
}
128132
}

src/test/java/org/tinspin/index/critbit/TestCritBit.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.Arrays;
2929
import java.util.Random;
3030

31+
import org.junit.BeforeClass;
3132
import org.junit.Test;
3233
import org.tinspin.index.critbit.CritBit;
3334
import org.tinspin.index.critbit.CritBit1D;
@@ -48,7 +49,11 @@ public class TestCritBit {
4849
private CritBit1D<Integer> newCritBit(int depth) {
4950
return CritBit.create1D(depth);
5051
}
51-
52+
53+
@BeforeClass public static void beforeClass() {
54+
Examples.PRINT = false;
55+
}
56+
5257
@Test
5358
public void testInsertIntRBug1() {
5459
randomInsertCheck(1000, 7374, 32);

src/test/java/org/tinspin/index/phtree/PhTreeTest.java

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@
2525
import java.util.Random;
2626

2727
import ch.ethz.globis.tinspin.TestStats;
28+
import org.junit.BeforeClass;
2829
import org.junit.Test;
2930
import org.tinspin.index.BoxMap;
3031
import org.tinspin.index.array.RectArray;
3132
import org.tinspin.index.test.util.JmxTools;
3233
import org.tinspin.index.test.util.TestBox;
3334
import org.tinspin.index.test.util.TestBoxCube;
3435
import org.tinspin.index.test.util.TestInstances.TST;
36+
import org.tinspin.index.test.util.TestRunner;
3537

3638
import static org.tinspin.index.Index.*;
3739

@@ -42,6 +44,11 @@ public class PhTreeTest {
4244
private static final double param1 = 0.01;
4345
private static final RectComp COMP = new RectComp();
4446

47+
@BeforeClass
48+
public static void beforeClass() {
49+
TestRunner.PRINT = false;
50+
}
51+
4552
@Test
4653
public void testR() {
4754
Random R = new Random(0);
@@ -76,7 +83,7 @@ private void load(BoxMap<Integer> tree, double[] data) {
7683
private void repeatQuery(TestBox test, BoxMap<Integer> tree1, BoxMap<Integer> tree2, int repeat) {
7784
int dims = DIM;
7885
//log("N=" + N);
79-
log("querying index ... repeat = " + repeat);
86+
println("querying index ... repeat = " + repeat);
8087
double[][] lower = new double[repeat][dims];
8188
double[][] upper = new double[repeat][dims];
8289
test.generateWindowQueries(lower, upper);
@@ -85,7 +92,7 @@ private void repeatQuery(TestBox test, BoxMap<Integer> tree1, BoxMap<Integer> tr
8592
int n = 0;
8693
n = repeatQueries(tree1, tree2, lower, upper);
8794
long t2 = System.currentTimeMillis();
88-
log("Query time: " + (t2-t1) + " ms -> " + (t2-t1)/(double)repeat + " ms/q -> " +
95+
println("Query time: " + (t2-t1) + " ms -> " + (t2-t1)/(double)repeat + " ms/q -> " +
8996
(t2-t1)*1000*1000/(double)n + " ns/q/r (n=" + n + ")");
9097
}
9198

@@ -107,24 +114,24 @@ private int repeatQueries(BoxMap<Integer> tree1, BoxMap<Integer> tree2, double[]
107114
n2++;
108115
}
109116
if (n1 != n2) {
110-
log("n1/n2=" + n1 + "/" + n2);
111-
log("q=" + Arrays.toString(lower[i]) + "/" + Arrays.toString(upper[i]));
117+
println("n1/n2=" + n1 + "/" + n2);
118+
println("q=" + Arrays.toString(lower[i]) + "/" + Arrays.toString(upper[i]));
112119
set1.sort(COMP);
113120
set2.sort(COMP);
114121
for (int j = 0; j < set1.size(); j++) {
115122
BoxEntry<Integer> e1 = set1.get(j);
116123
BoxEntry<Integer> e2 = set2.get(j);
117124
if (!Arrays.equals(e1.min(), e2.min()) ||
118125
!Arrays.equals(e1.max(), e2.max())) {
119-
log("j=" + j + " mismatch: " + e1 + " -/- " + e2);
126+
println("j=" + j + " mismatch: " + e1 + " -/- " + e2);
120127
}
121128
}
122129
}
123130
assertEquals(n1, n2);
124131
n += n1;
125-
if (i%10 == 0) System.out.print('.');
132+
if (i%10 == 0) print(".");
126133
}
127-
System.out.println();
134+
println("");
128135
//log("n=" + n/(double)lower.length);
129136
return n;
130137
}
@@ -146,9 +153,17 @@ public int compare(BoxEntry<?> o1, BoxEntry<?> o2) {
146153
return 0;
147154
}
148155
}
149-
150-
private static void log(String string) {
151-
System.out.println(string);
156+
157+
private static void println(String string) {
158+
if (TestRunner.PRINT) {
159+
System.out.println(string);
160+
}
161+
}
162+
163+
private static void print(String string) {
164+
if (TestRunner.PRINT) {
165+
System.out.print(string);
166+
}
152167
}
153168

154169
}

0 commit comments

Comments
 (0)