forked from fast-pack/JavaFastPFOR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXorBinaryPackingTest.java
More file actions
108 lines (90 loc) · 2.53 KB
/
Copy pathXorBinaryPackingTest.java
File metadata and controls
108 lines (90 loc) · 2.53 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
/**
* 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 java.util.Arrays;
import me.lemire.integercompression.differential.XorBinaryPacking;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* @author lemire
*
*/
@SuppressWarnings({ "static-method" })
public final class XorBinaryPackingTest
{
private static void checkCompressAndUncompress(String label, int[] data) {
XorBinaryPacking codec = new XorBinaryPacking();
int[] compBuf = TestUtils.compress(codec, data);
int[] decompBuf = TestUtils.uncompress(codec, compBuf, data.length);
assertArrayEquals(data, decompBuf);
}
/**
*
*/
@Test
public void compressAndUncompress0() {
int[] data = new int[128];
Arrays.fill(data, 0, 31, 1);
Arrays.fill(data, 32, 63, 2);
Arrays.fill(data, 64, 95, 4);
Arrays.fill(data, 96, 127, 8);
checkCompressAndUncompress("compressAndUncompress0", data);
}
/**
*
*/
@Test
public void compressAndUncompress1() {
int[] data = new int[128];
for (int i = 0; i < data.length; ++i) {
data[i] = i;
}
checkCompressAndUncompress("compressAndUncompress1", data);
}
/**
*
*/
@Test
public void compressAndUncompress2() {
int[] data = new int[128];
for (int i = 0; i < data.length; ++i) {
data[i] = i * (i + 1) / 2;
}
checkCompressAndUncompress("compressAndUncompress2", data);
}
/**
*
*/
@Test
public void compressAndUncompress3() {
int[] data = new int[256];
Arrays.fill(data, 0, 127, 2);
Arrays.fill(data, 128, 255, 3);
checkCompressAndUncompress("compressAndUncompress3", data);
}
/**
*
*/
@Test
public void compressAndUncompress4() {
int[] data = new int[256];
Arrays.fill(data, 0, 127, 3);
Arrays.fill(data, 128, 255, 2);
checkCompressAndUncompress("compressAndUncompress4", data);
}
/**
*
*/
@Test
public void compressAndUncompress5() {
int[] data = new int[256];
for (int i = 0; i < data.length; ++i) {
data[i] = i;
}
checkCompressAndUncompress("compressAndUncompress5", data);
}
}