forked from fast-pack/JavaFastPFOR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdhocTest.java
More file actions
131 lines (112 loc) · 3.61 KB
/
Copy pathAdhocTest.java
File metadata and controls
131 lines (112 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/**
* This code is released under the
* Apache License Version 2.0 http://www.apache.org/licenses/.
*
* (c) Daniel Lemire, http://lemire.me/en/
*/
package me.lemire.integercompression;
import org.junit.Assert;
import org.junit.Test;
import me.lemire.integercompression.differential.*;
import static me.lemire.integercompression.TestUtils.*;
import java.util.Arrays;
/**
* Collection of adhoc tests.
*/
@SuppressWarnings({ "static-method" })
public class AdhocTest {
/**
*
*/
@Test
public void testIssue29() {
for(int x = 0; x < 64; x++) {
int[] a = {2, 3, 4, 5};
int[] b = new int[90];
int[] c = new int[a.length];
IntegerCODEC codec = new Composition(new BinaryPacking(), new VariableByte());
IntWrapper aOffset = new IntWrapper(0);
IntWrapper bOffset = new IntWrapper(x);
codec.compress(a, aOffset, a.length, b, bOffset);
int len = bOffset.get() - x;
bOffset.set(x);
IntWrapper cOffset = new IntWrapper(0);
codec.uncompress(b, bOffset, len, c, cOffset);
Assert.assertArrayEquals(a,c);
}
}
/**
*
*/
@Test
public void testIssue29b() {
for(int x = 0; x < 64; x++) {
int[] a = {2, 3, 4, 5};
int[] b = new int[90];
int[] c = new int[a.length];
SkippableIntegerCODEC codec = new SkippableComposition(new BinaryPacking(), new VariableByte());
IntWrapper aOffset = new IntWrapper(0);
IntWrapper bOffset = new IntWrapper(x);
codec.headlessCompress(a, aOffset, a.length, b, bOffset);
int len = bOffset.get() - x;
bOffset.set(x);
IntWrapper cOffset = new IntWrapper(0);
codec.headlessUncompress(b, bOffset, len, c, cOffset, a.length);
Assert.assertArrayEquals(a,c);
}
}
/**
*
*/
@Test
public void testIssue41() {
for (int x = 0; x < 64; x++) {
int[] a = { 2, 3, 4, 5 };
int[] b = new int[90];
int[] c = new int[a.length];
SkippableIntegratedIntegerCODEC codec = new SkippableIntegratedComposition(new IntegratedBinaryPacking(),
new IntegratedVariableByte());
IntWrapper aOffset = new IntWrapper(0);
IntWrapper bOffset = new IntWrapper(x);
IntWrapper initValue = new IntWrapper(0);
codec.headlessCompress(a, aOffset, a.length, b, bOffset, initValue);
int len = bOffset.get() - x;
bOffset.set(x);
IntWrapper cOffset = new IntWrapper(0);
initValue = new IntWrapper(0);
codec.headlessUncompress(b, bOffset, len, c, cOffset, a.length, initValue);
Assert.assertArrayEquals(a, c);
}
}
/**
* a test
*/
@Test
public void biggerCompressedArray0() {
// No problem: for comparison.
IntegerCODEC c = new Composition(new FastPFOR128(), new VariableByte());
assertSymmetry(c, 0, 16384);
c = new Composition(new FastPFOR(), new VariableByte());
assertSymmetry(c, 0, 16384);
}
/**
* a test
*/
@Test
public void biggerCompressedArray1() {
// Compressed array is bigger than original, because of VariableByte.
IntegerCODEC c = new VariableByte();
assertSymmetry(c, -1);
}
/**
* a test
*/
@Test
public void biggerCompressedArray2() {
// Compressed array is bigger than original, because of Composition.
IntegerCODEC c = new Composition(new FastPFOR128(), new VariableByte());
assertSymmetry(c, 65535, 65535);
c = new Composition(new FastPFOR(), new VariableByte());
assertSymmetry(c, 65535, 65535);
}
}