-
Notifications
You must be signed in to change notification settings - Fork 4
/
compress_test.go
455 lines (393 loc) · 52.6 KB
/
compress_test.go
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
package intcomp_test
import (
"math"
"testing"
"github.com/ronanh/intcomp"
)
func TestCompressCombinedInt32(t *testing.T) {
var testInput = []int32{0, 202, -320, math.MaxInt32, math.MinInt32, math.MaxInt32, 529, 638, 838, 949, 1151, 1257, 1454, 1561, 1759, 1994, 2105, 2307, 2413, 2610, 2716, 2913, 3146, 3253, 3360, 3558, 3665, 3863, 4061, 4168, 4366, 4472, 4578, 4775, 4972, 5079, 5277, 5386,
5586, 5694, 5801, 6000, 6106, 6304, 6501, 6627, 6844, 6950, 7059, 7256, 7456, 7563, 7672, 7870, 8070, 8309, 8418, 8618, 8857, 8961, 9156, 9269, 9473, 9579, 9776, 9883, 10081, 10187, 10384, 10491, 10689, 10826, 11054, 11180, 11287, 11504,
11610, 11808, 11915, 12022, 12219, 12417, 12615, 12721, 12918, 13024, 13221, 13328, 13526, 13632, 13735, 13842, 14039, 14233, 14431, 14537, 14734, 14841, 15039, 15145, 15252, 15360, 15557, 15755, 15954, 16093, 16323, 16430, 16628, 16734,
16840, 17037, 17234, 17467, 17700, 17806, 18003, 18236, 18342, 18539, 18645, 18842, 18948, 19061, 19258, 19462, 19568, 19765, 19871, 20068, 20175, 20373, 20489, 20696, 20802, 20909, 21106, 21304, 21411, 21609, 21715, 21912, 22018, 22215,
22322, 22428, 22626, 22823, 22929, 23126, 23230, 23336, 23442, 23637, 23834, 24031, 24137, 24243, 24440, 24637, 24744, 24850, 25048, 25245, 25352, 25459, 25657, 25764, 25962, 26160, 26266, 26372, 26569, 26676, 26873, 27071, 27187, 27394,
27500, 27606, 27712, 27819, 28016, 28213, 28410, 28608, 28726, 28832, 28939, 29046, 29243, 29452, 29650, 29756, 29954, 30062, 30168, 30365, 30562, 30761, 30867, 30973, 31079, 31276, 31383, 31580, 31777, 31900, 32098, 32204, 32310, 32524,
32630, 32827, 33024, 33221, 33327, 33524, 33631, 33737, 33935, 34132, 34238, 34435, 34542, 34740, 34846, 34949, 35146, 35340, 35447, 35645, 35751, 35948, 36054, 36251, 36358, 36465, 36571, 36678, 36876, 37074, 37271, 37469, 37576, 37774,
37998, 38104, 38210, 38407, 38604, 38725, 38937, 39044, 39148, 39346, 39452, 39647, 39753, 39950, 40147, 40251, 40357, 40463, 40658, 40765, 40883, 41080, 41277, 41383, 41581, 41790, 41896, 42093, 42290, 42396, 42502, 42608, 42805, 42911,
43108, 43305, 43502, 43608, 43714, 43911, 44108, 44214, 44411, 44517, 44714, 44820, 44926, 45032, 45141, 45338, 45444, 45641, 45747, 45944, 46051, 46248, 46354, 46554, 46751, 46949, 47146, 47252, 47449, 47562, 47766, 47875, 48075, 48314,
48423, 48623, 48862, 48968, 49165, 49271, 49468, 49572, 49767, 49880, 49986, 50190, 50387, 50493, 50600, 50797, 50912, 51110, 51316, 51422, 51531, 51731, 51928, 52034, 52231, 52337, 52534, 52640, 52746, 52943, 53140, 53246, 53443, 53676,
53782, 53979, 54093, 54298, 54404, 54601, 54834, 54959, 55072, 55288, 55492, 55598, 55795, 55908, 56112, 56225, 56343, 56547, 56756, 56865, 57065, 57178, 57382, 57491, 57691, 57798, 57996, 58110, 58315, 58422, 58620, 58855, 58962, 59160,
59266, 59463, 59696, 59802, 59999, 60232, 60339, 60537, 60644, 60842, 60959, 61167, 61280, 61394, 61505, 61707, 61911, 62116, 62238, 62352, 62565, 62770, 62883, 62989, 63193, 63390, 63501, 63703, 63812, 64012, 64121, 64321, 64560, 64669,
64869, 65108, 65219, 65421, 65527, 65724, 65835, 66037, 66145, 66344, 66581, 66687, 66794, 66905, 67018, 67124, 67326, 67530, 67727, 67925, 68122, 68236, 68441, 68547, 68744, 68850, 69047, 69160, 69364, 69490, 69707, 69980, 70091, 70202,
70313, 70515, 70717, 70919, 71025, 71222, 71455, 71568, 71772, 72019, 72128, 72328, 72435, 72633, 72857, 72968, 73170, 73277, 73475, 73710, 73836, 73942, 74159, 74356, 74463, 74570, 74768, 74966, 75072, 75269, 75382, 75586, 75692, 75889,
75996, 76111, 76309, 76515, 76622, 76820, 76927, 77125, 77236, 77438, 77559, 77666, 77878, 77990, 78188, 78391, 78497, -320, math.MaxInt32, math.MinInt32, math.MaxInt32}
output := intcomp.CompressInt32(testInput, make([]uint32, 0, 100))
input2 := intcomp.UncompressInt32(output, make([]int32, 0, 100))
t.Logf("input len: %d, output len: %d\n", len(testInput), len(output))
if len(input2) != len(testInput) {
t.Fatalf("expected same len")
}
for i, v := range testInput {
if input2[i] != v {
t.Fatalf("i=%d, input2(%d) != input(%d)", i, input2[i], v)
}
}
}
func TestCompressCombinedInt32Multi(t *testing.T) {
var testInputs = [][]int32{{0, 202, -320, math.MaxInt32, math.MinInt32, math.MaxInt32, 529}, {638, 838, 949, 1151, 1257, 1454, 1561, 1759, 1994, 2105, 2307, 2413, 2610, 2716, 2913, 3146, 3253, 3360, 3558, 3665, 3863, 4061, 4168, 4366, 4472, 4578, 4775, 4972, 5079, 5277, 5386,
5586}, {5694, 5801, 6000, 6106, 6304, 6501, 6627, 6844, 6950, 7059, 7256, 7456, 7563, 7672, 7870, 8070, 8309, 8418, 8618, 8857, 8961, 9156, 9269, 9473, 9579, 9776, 9883, 10081, 10187, 10384, 10491, 10689, 10826, 11054, 11180, 11287, 11504,
11610}, {11808, 11915, 12022, 12219, 12417, 12615, 12721, 12918, 13024, 13221, 13328, 13526, 13632, 13735, 13842, 14039, 14233, 14431, 14537, 14734, 14841, 15039, 15145, 15252, 15360, 15557, 15755, 15954, 16093, 16323, 16430, 16628, 16734,
16840}, {17037, 17234, 17467, 17700, 17806, 18003, 18236, 18342, 18539, 18645, 18842, 18948, 19061, 19258, 19462, 19568, 19765, 19871, 20068, 20175, 20373, 20489, 20696, 20802, 20909, 21106, 21304, 21411, 21609, 21715, 21912, 22018, 22215,
22322}, {22428, 22626, 22823, 22929, 23126, 23230, 23336, 23442, 23637, 23834, 24031, 24137, 24243, 24440, 24637, 24744, 24850, 25048, 25245, 25352, 25459, 25657, 25764, 25962, 26160, 26266, 26372, 26569, 26676, 26873, 27071, 27187, 27394,
27500}, {27606, 27712, 27819, 28016, 28213, 28410, 28608, 28726, 28832, 28939, 29046, 29243, 29452, 29650, 29756, 29954, 30062, 30168, 30365, 30562, 30761, 30867, 30973, 31079, 31276, 31383, 31580, 31777, 31900, 32098, 32204, 32310, 32524,
32630}, {32827, 33024, 33221, 33327, 33524, 33631, 33737, 33935, 34132, 34238, 34435, 34542, 34740, 34846, 34949, 35146, 35340, 35447, 35645, 35751, 35948, 36054, 36251, 36358, 36465, 36571, 36678, 36876, 37074, 37271, 37469, 37576, 37774,
37998}, {38104, 38210, 38407, 38604, 38725, 38937, 39044, 39148, 39346, 39452, 39647, 39753, 39950, 40147, 40251, 40357, 40463, 40658, 40765, 40883, 41080, 41277, 41383, 41581, 41790, 41896, 42093, 42290, 42396, 42502, 42608, 42805, 42911,
43108}, {43305, 43502, 43608, 43714, 43911, 44108, 44214, 44411, 44517, 44714, 44820, 44926, 45032, 45141, 45338, 45444, 45641, 45747, 45944, 46051, 46248, 46354, 46554, 46751, 46949, 47146, 47252, 47449, 47562, 47766, 47875, 48075, 48314,
48423}, {48623, 48862, 48968, 49165, 49271, 49468, 49572, 49767, 49880, 49986, 50190, 50387, 50493, 50600, 50797, 50912, 51110, 51316, 51422, 51531, 51731, 51928, 52034, 52231, 52337, 52534, 52640, 52746, 52943, 53140, 53246, 53443, 53676,
53782}, {53979, 54093, 54298, 54404, 54601, 54834, 54959, 55072, 55288, 55492, 55598, 55795, 55908, 56112, 56225, 56343, 56547, 56756, 56865, 57065, 57178, 57382, 57491, 57691, 57798, 57996, 58110, 58315, 58422, 58620, 58855, 58962, 59160,
59266}, {59463, 59696, 59802, 59999, 60232, 60339, 60537, 60644, 60842, 60959, 61167, 61280, 61394, 61505, 61707, 61911, 62116, 62238, 62352, 62565, 62770, 62883, 62989, 63193, 63390, 63501, 63703, 63812, 64012, 64121, 64321, 64560, 64669,
64869}, {65108, 65219, 65421, 65527, 65724, 65835, 66037, 66145, 66344, 66581, 66687, 66794, 66905, 67018, 67124, 67326, 67530, 67727, 67925, 68122, 68236, 68441, 68547, 68744, 68850, 69047, 69160, 69364, 69490, 69707, 69980, 70091, 70202,
70313}, {70515, 70717, 70919, 71025, 71222, 71455, 71568, 71772, 72019, 72128, 72328, 72435, 72633, 72857, 72968, 73170, 73277, 73475, 73710, 73836, 73942, 74159, 74356, 74463, 74570, 74768, 74966, 75072, 75269, 75382, 75586, 75692, 75889,
75996}, {76111, 76309, 76515, 76622, 76820, 76927, 77125, 77236, 77438, 77559, 77666, 77878, 77990, 78188, 78391, 78497, -320, math.MaxInt32, math.MinInt32, math.MaxInt32}}
var testInput []int32
var output []uint32
for _, ti := range testInputs {
output = intcomp.CompressInt32(ti, output)
testInput = append(testInput, ti...)
}
input2 := intcomp.UncompressInt32(output, make([]int32, 0, 100))
t.Logf("input len: %d, output len: %d\n", len(testInput), len(output))
if len(input2) != len(testInput) {
t.Fatalf("expected same len")
}
for i, v := range testInput {
if input2[i] != v {
t.Fatalf("i=%d, input2(%d) != input(%d)", i, input2[i], v)
}
}
}
func TestCompressCombinedInt32_trailing(t *testing.T) {
var testInput = []int32{0, 202, -320, 529, 638, 838, 949, 1151, 1257, 1454, 1561, 1759, 1994, 2105, 2307, 2413, 2610, 2716, 2913, 3146, 3253, 3360, 3558, 3665, 3863, 4061, 4168, 4366, 4472, 4578, 4775, 4972, 5079, 5277, 5386,
5586, 5694, 5801, 6000, 6106, 6304, 6501, 6627, 6844, 6950, 7059, 7256, 7456, 7563, 7672, 7870, 8070, 8309, 8418, 8618, 8857, 8961, 9156, 9269, 9473, 9579, 9776, 9883, 10081, 10187, 10384, 10491, 10689, 10826, 11054, 11180, 11287, 11504,
11610, 11808, 11915, 12022, 12219, 12417, 12615, 12721, 12918, 13024, 13221, 13328, 13526, 13632, 13735, 13842, 14039, 14233, 14431, 14537, 14734, 14841, 15039, 15145, 15252, 15360, 15557, 15755, 15954, 16093, 16323, 16430, 16628, 16734,
16840, 17037, 17234, 17467, 17700, 17806, 18003, 18236, 18342, 18539, 18645, 18842, 18948, 19061, 19258, 19462, 19568, 19765, 19871, 20068, 20175, 20373, 20489, 20696, 20802, 20909, 21106, 21304, 21411, 21609, 21715, 21912, 22018, 22215,
22322, 22428, 22626, 22823, 22929, 23126, 23230, 23336, 23442, 23637, 23834, 24031, 24137, 24243, 24440, 24637, 24744, 24850, 25048, 25245, 25352, 25459, 25657, 25764, 25962, 26160, 26266, 26372, 26569, 26676, 26873, 27071, 27187, 27394,
27500, 27606, 27712, 27819, 28016, 28213, 28410, 28608, 28726, 28832, 28939, 29046, 29243, 29452, 29650, 29756, 29954, 30062, 30168, 30365, 30562, 30761, 30867, 30973, 31079, 31276, 31383, 31580, 31777, 31900, 32098, 32204, 32310, 32524,
32630, 32827, 33024, 33221, 33327, 33524, 33631, 33737, 33935, 34132, 34238, 34435, 34542, 34740, 34846, 34949, 35146, 35340, 35447, 35645, 35751, 35948, 36054, 36251, 36358, 36465, 36571, 36678, 36876, 37074, 37271, 37469, 37576, 37774,
37998, 38104, 38210, 38407, 38604, 38725, 38937, 39044, 39148, 39346, 39452, 39647, 39753, 39950, 40147, 40251, 40357, 40463, 40658, 40765, 40883, 41080, 41277, 41383, 41581, 41790, 41896, 42093, 42290, 42396, 42502, 42608, 42805, 42911,
43108, 43305, 43502, 43608, 43714, 43911, 44108, 44214, 44411, 44517, 44714, 44820, 44926, 45032, 45141, 45338, 45444, 45641, 45747, 45944, 46051, 46248, 46354, 46554, 46751, 46949, 47146, 47252, 47449, 47562, 47766, 47875, 48075, 48314,
48423, 48623, 48862, 48968, 49165, 49271, 49468, 49572, 49767, 49880, 49986, 50190, 50387, 50493, 50600, 50797, 50912, 51110, 51316, 51422, 51531, 51731, 51928, 52034, 52231, 52337, 52534, 52640, 52746, 52943, 53140, 53246, 53443, 53676,
53782, 53979, 54093, 54298, 54404, 54601, 54834, 54959, 55072, 55288, 55492, 55598, 55795, 55908, 56112, 56225, 56343, 56547, 56756, 56865, 57065, 57178, 57382, 57491, 57691, 57798, 57996, 58110, 58315, 58422, 58620, 58855, 58962, 59160,
59266, 59463, 59696, 59802, 59999, 60232, 60339, 60537, 60644, 60842, 60959, 61167, 61280, 61394, 61505, 61707, 61911, 62116, 62238, 62352, 62565, 62770, 62883, 62989, 63193, 63390, 63501, 63703, 63812, 64012, 64121, 64321, 64560, 64669,
64869, 65108, 65219, 65421, 65527, 65724, 65835, 66037, 66145, 66344, 66581, 66687, 66794, 66905, 67018, 67124, 67326, 67530, 67727, 67925, 68122, 68236, 68441, 68547, 68744, 68850, 69047, 69160, 69364, 69490, 69707, 69980, 70091, 70202,
70313, 70515, 70717, 70919, 71025, 71222, 71455, 71568, 71772, 72019, 72128, 72328, 72435, 72633, 72857, 72968, 73170, 73277, 73475, 73710, 73836, 73942, 74159, 74356, 74463, 74570, 74768, 74966, 75072, 75269, 75382, 75586, 75692, 75889,
75996, 76111, 76309, 76515, 76622, 76820, 76927, 77125, 77236, 77438, 77559, 77666, 77878, 77990, 78188, 78391, 78497, -320}
for i := range testInput {
testInput[i] *= 8
}
output := intcomp.CompressInt32(testInput, make([]uint32, 0, 100))
input2 := intcomp.UncompressInt32(output, make([]int32, 0, 100))
t.Logf("input len: %d, output len: %d\n", len(testInput), len(output))
if len(input2) != len(testInput) {
t.Fatalf("expected same len")
}
for i, v := range testInput {
if input2[i] != v {
t.Fatalf("i=%d, input2(%d) != input(%d)", i, input2[i], v)
}
}
}
func TestCompressCombinedUint32(t *testing.T) {
var testInput = []uint32{0, 202, 0, math.MaxUint32, 0, math.MaxInt32, 529, 638, 838, 949, 1151, 1257, 1454, 1561, 1759, 1994, 2105, 2307, 2413, 2610, 2716, 2913, 3146, 3253, 3360, 3558, 3665, 3863, 4061, 4168, 4366, 4472, 4578, 4775, 4972, 5079, 5277, 5386,
5586, 5694, 5801, 6000, 6106, 6304, 6501, 6627, 6844, 6950, 7059, 7256, 7456, 7563, 7672, 7870, 8070, 8309, 8418, 8618, 8857, 8961, 9156, 9269, 9473, 9579, 9776, 9883, 10081, 10187, 10384, 10491, 10689, 10826, 11054, 11180, 11287, 11504,
11610, 11808, 11915, 12022, 12219, 12417, 12615, 12721, 12918, 13024, 13221, 13328, 13526, 13632, 13735, 13842, 14039, 14233, 14431, 14537, 14734, 14841, 15039, 15145, 15252, 15360, 15557, 15755, 15954, 16093, 16323, 16430, 16628, 16734,
16840, 17037, 17234, 17467, 17700, 17806, 18003, 18236, 18342, 18539, 18645, 18842, 18948, 19061, 19258, 19462, 19568, 19765, 19871, 20068, 20175, 20373, 20489, 20696, 20802, 20909, 21106, 21304, 21411, 21609, 21715, 21912, 22018, 22215,
22322, 22428, 22626, 22823, 22929, 23126, 23230, 23336, 23442, 23637, 23834, 24031, 24137, 24243, 24440, 24637, 24744, 24850, 25048, 25245, 25352, 25459, 25657, 25764, 25962, 26160, 26266, 26372, 26569, 26676, 26873, 27071, 27187, 27394,
27500, 27606, 27712, 27819, 28016, 28213, 28410, 28608, 28726, 28832, 28939, 29046, 29243, 29452, 29650, 29756, 29954, 30062, 30168, 30365, 30562, 30761, 30867, 30973, 31079, 31276, 31383, 31580, 31777, 31900, 32098, 32204, 32310, 32524,
32630, 32827, 33024, 33221, 33327, 33524, 33631, 33737, 33935, 34132, 34238, 34435, 34542, 34740, 34846, 34949, 35146, 35340, 35447, 35645, 35751, 35948, 36054, 36251, 36358, 36465, 36571, 36678, 36876, 37074, 37271, 37469, 37576, 37774,
37998, 38104, 38210, 38407, 38604, 38725, 38937, 39044, 39148, 39346, 39452, 39647, 39753, 39950, 40147, 40251, 40357, 40463, 40658, 40765, 40883, 41080, 41277, 41383, 41581, 41790, 41896, 42093, 42290, 42396, 42502, 42608, 42805, 42911,
43108, 43305, 43502, 43608, 43714, 43911, 44108, 44214, 44411, 44517, 44714, 44820, 44926, 45032, 45141, 45338, 45444, 45641, 45747, 45944, 46051, 46248, 46354, 46554, 46751, 46949, 47146, 47252, 47449, 47562, 47766, 47875, 48075, 48314,
48423, 48623, 48862, 48968, 49165, 49271, 49468, 49572, 49767, 49880, 49986, 50190, 50387, 50493, 50600, 50797, 50912, 51110, 51316, 51422, 51531, 51731, 51928, 52034, 52231, 52337, 52534, 52640, 52746, 52943, 53140, 53246, 53443, 53676,
53782, 53979, 54093, 54298, 54404, 54601, 54834, 54959, 55072, 55288, 55492, 55598, 55795, 55908, 56112, 56225, 56343, 56547, 56756, 56865, 57065, 57178, 57382, 57491, 57691, 57798, 57996, 58110, 58315, 58422, 58620, 58855, 58962, 59160,
59266, 59463, 59696, 59802, 59999, 60232, 60339, 60537, 60644, 60842, 60959, 61167, 61280, 61394, 61505, 61707, 61911, 62116, 62238, 62352, 62565, 62770, 62883, 62989, 63193, 63390, 63501, 63703, 63812, 64012, 64121, 64321, 64560, 64669,
64869, 65108, 65219, 65421, 65527, 65724, 65835, 66037, 66145, 66344, 66581, 66687, 66794, 66905, 67018, 67124, 67326, 67530, 67727, 67925, 68122, 68236, 68441, 68547, 68744, 68850, 69047, 69160, 69364, 69490, 69707, 69980, 70091, 70202,
70313, 70515, 70717, 70919, 71025, 71222, 71455, 71568, 71772, 72019, 72128, 72328, 72435, 72633, 72857, 72968, 73170, 73277, 73475, 73710, 73836, 73942, 74159, 74356, 74463, 74570, 74768, 74966, 75072, 75269, 75382, 75586, 75692, 75889,
75996, 76111, 76309, 76515, 76622, 76820, 76927, 77125, 77236, 77438, 77559, 77666, 77878, 77990, 78188, 78391, 78497, 320, math.MaxUint32, 0, math.MaxUint32}
output := intcomp.CompressUint32(testInput, make([]uint32, 0, 100))
input2 := intcomp.UncompressUint32(output, make([]uint32, 0, 100))
t.Logf("input len: %d, output len: %d\n", len(testInput), len(output))
if len(input2) != len(testInput) {
t.Fatalf("expected same len")
}
for i, v := range testInput {
if input2[i] != v {
t.Fatalf("i=%d, input2(%d) != input(%d)", i, input2[i], v)
}
}
}
func TestCompressCombinedUint32Multi(t *testing.T) {
var testInputs = [][]uint32{{0, 202, 320, math.MaxUint32, 0, math.MaxUint32, 529}, {638, 838, 949, 1151, 1257, 1454, 1561, 1759, 1994, 2105, 2307, 2413, 2610, 2716, 2913, 3146, 3253, 3360, 3558, 3665, 3863, 4061, 4168, 4366, 4472, 4578, 4775, 4972, 5079, 5277, 5386,
5586}, {5694, 5801, 6000, 6106, 6304, 6501, 6627, 6844, 6950, 7059, 7256, 7456, 7563, 7672, 7870, 8070, 8309, 8418, 8618, 8857, 8961, 9156, 9269, 9473, 9579, 9776, 9883, 10081, 10187, 10384, 10491, 10689, 10826, 11054, 11180, 11287, 11504,
11610}, {11808, 11915, 12022, 12219, 12417, 12615, 12721, 12918, 13024, 13221, 13328, 13526, 13632, 13735, 13842, 14039, 14233, 14431, 14537, 14734, 14841, 15039, 15145, 15252, 15360, 15557, 15755, 15954, 16093, 16323, 16430, 16628, 16734,
16840}, {17037, 17234, 17467, 17700, 17806, 18003, 18236, 18342, 18539, 18645, 18842, 18948, 19061, 19258, 19462, 19568, 19765, 19871, 20068, 20175, 20373, 20489, 20696, 20802, 20909, 21106, 21304, 21411, 21609, 21715, 21912, 22018, 22215,
22322}, {22428, 22626, 22823, 22929, 23126, 23230, 23336, 23442, 23637, 23834, 24031, 24137, 24243, 24440, 24637, 24744, 24850, 25048, 25245, 25352, 25459, 25657, 25764, 25962, 26160, 26266, 26372, 26569, 26676, 26873, 27071, 27187, 27394,
27500}, {27606, 27712, 27819, 28016, 28213, 28410, 28608, 28726, 28832, 28939, 29046, 29243, 29452, 29650, 29756, 29954, 30062, 30168, 30365, 30562, 30761, 30867, 30973, 31079, 31276, 31383, 31580, 31777, 31900, 32098, 32204, 32310, 32524,
32630}, {32827, 33024, 33221, 33327, 33524, 33631, 33737, 33935, 34132, 34238, 34435, 34542, 34740, 34846, 34949, 35146, 35340, 35447, 35645, 35751, 35948, 36054, 36251, 36358, 36465, 36571, 36678, 36876, 37074, 37271, 37469, 37576, 37774,
37998}, {38104, 38210, 38407, 38604, 38725, 38937, 39044, 39148, 39346, 39452, 39647, 39753, 39950, 40147, 40251, 40357, 40463, 40658, 40765, 40883, 41080, 41277, 41383, 41581, 41790, 41896, 42093, 42290, 42396, 42502, 42608, 42805, 42911,
43108}, {43305, 43502, 43608, 43714, 43911, 44108, 44214, 44411, 44517, 44714, 44820, 44926, 45032, 45141, 45338, 45444, 45641, 45747, 45944, 46051, 46248, 46354, 46554, 46751, 46949, 47146, 47252, 47449, 47562, 47766, 47875, 48075, 48314,
48423}, {48623, 48862, 48968, 49165, 49271, 49468, 49572, 49767, 49880, 49986, 50190, 50387, 50493, 50600, 50797, 50912, 51110, 51316, 51422, 51531, 51731, 51928, 52034, 52231, 52337, 52534, 52640, 52746, 52943, 53140, 53246, 53443, 53676,
53782}, {53979, 54093, 54298, 54404, 54601, 54834, 54959, 55072, 55288, 55492, 55598, 55795, 55908, 56112, 56225, 56343, 56547, 56756, 56865, 57065, 57178, 57382, 57491, 57691, 57798, 57996, 58110, 58315, 58422, 58620, 58855, 58962, 59160,
59266}, {59463, 59696, 59802, 59999, 60232, 60339, 60537, 60644, 60842, 60959, 61167, 61280, 61394, 61505, 61707, 61911, 62116, 62238, 62352, 62565, 62770, 62883, 62989, 63193, 63390, 63501, 63703, 63812, 64012, 64121, 64321, 64560, 64669,
64869}, {65108, 65219, 65421, 65527, 65724, 65835, 66037, 66145, 66344, 66581, 66687, 66794, 66905, 67018, 67124, 67326, 67530, 67727, 67925, 68122, 68236, 68441, 68547, 68744, 68850, 69047, 69160, 69364, 69490, 69707, 69980, 70091, 70202,
70313}, {70515, 70717, 70919, 71025, 71222, 71455, 71568, 71772, 72019, 72128, 72328, 72435, 72633, 72857, 72968, 73170, 73277, 73475, 73710, 73836, 73942, 74159, 74356, 74463, 74570, 74768, 74966, 75072, 75269, 75382, 75586, 75692, 75889,
75996}, {76111, 76309, 76515, 76622, 76820, 76927, 77125, 77236, 77438, 77559, 77666, 77878, 77990, 78188, 78391, 78497, 320, math.MaxUint32, 0, math.MaxUint32}}
var testInput []uint32
var output []uint32
for _, ti := range testInputs {
output = intcomp.CompressUint32(ti, output)
testInput = append(testInput, ti...)
}
input2 := intcomp.UncompressUint32(output, make([]uint32, 0, 100))
t.Logf("input len: %d, output len: %d\n", len(testInput), len(output))
if len(input2) != len(testInput) {
t.Fatalf("expected same len")
}
for i, v := range testInput {
if input2[i] != v {
t.Fatalf("i=%d, input2(%d) != input(%d)", i, input2[i], v)
}
}
}
func TestCompressCombinedInt64(t *testing.T) {
var testInput = []int64{0, 202, -320, math.MaxInt64, math.MinInt64, math.MaxInt64, 529, 638, 838, 949, 1151, 1257, 1454, 1561, 1759, 1994, 2105, 2307, 2413, 2610, 2716, 2913, 3146, 3253, 3360, 3558, 3665, 3863, 4061, 4168, 4366, 4472, 4578, 4775, 4972, 5079, 5277, 5386,
5586, 5694, 5801, 6000, 6106, 6304, 6501, 6627, 6844, 6950, 7059, 7256, 7456, 7563, 7672, 7870, 8070, 8309, 8418, 8618, 8857, 8961, 9156, 9269, 9473, 9579, 9776, 9883, 10081, 10187, 10384, 10491, 10689, 10826, 11054, 11180, 11287, 11504,
11610, 11808, 11915, 12022, 12219, 12417, 12615, 12721, 12918, 13024, 13221, 13328, 13526, 13632, 13735, 13842, 14039, 14233, 14431, 14537, 14734, 14841, 15039, 15145, 15252, 15360, 15557, 15755, 15954, 16093, 16323, 16430, 16628, 16734,
16840, 17037, 17234, 17467, 17700, 17806, 18003, 18236, 18342, 18539, 18645, 18842, 18948, 19061, 19258, 19462, 19568, 19765, 19871, 20068, 20175, 20373, 20489, 20696, 20802, 20909, 21106, 21304, 21411, 21609, 21715, 21912, 22018, 22215,
22322, 22428, 22626, 22823, 22929, 23126, 23230, 23336, 23442, 23637, 23834, 24031, 24137, 24243, 24440, 24637, 24744, 24850, 25048, 25245, 25352, 25459, 25657, 25764, 25962, 26160, 26266, 26372, 26569, 26676, 26873, 27071, 27187, 27394,
27500, 27606, 27712, 27819, 28016, 28213, 28410, 28608, 28726, 28832, 28939, 29046, 29243, 29452, 29650, 29756, 29954, 30062, 30168, 30365, 30562, 30761, 30867, 30973, 31079, 31276, 31383, 31580, 31777, 31900, 32098, 32204, 32310, 32524,
32630, 32827, 33024, 33221, 33327, 33524, 33631, 33737, 33935, 34132, 34238, 34435, 34542, 34740, 34846, 34949, 35146, 35340, 35447, 35645, 35751, 35948, 36054, 36251, 36358, 36465, 36571, 36678, 36876, 37074, 37271, 37469, 37576, 37774,
37998, 38104, 38210, 38407, 38604, 38725, 38937, 39044, 39148, 39346, 39452, 39647, 39753, 39950, 40147, 40251, 40357, 40463, 40658, 40765, 40883, 41080, 41277, 41383, 41581, 41790, 41896, 42093, 42290, 42396, 42502, 42608, 42805, 42911,
43108, 43305, 43502, 43608, 43714, 43911, 44108, 44214, 44411, 44517, 44714, 44820, 44926, 45032, 45141, 45338, 45444, 45641, 45747, 45944, 46051, 46248, 46354, 46554, 46751, 46949, 47146, 47252, 47449, 47562, 47766, 47875, 48075, 48314,
48423, 48623, 48862, 48968, 49165, 49271, 49468, 49572, 49767, 49880, 49986, 50190, 50387, 50493, 50600, 50797, 50912, 51110, 51316, 51422, 51531, 51731, 51928, 52034, 52231, 52337, 52534, 52640, 52746, 52943, 53140, 53246, 53443, 53676,
53782, 53979, 54093, 54298, 54404, 54601, 54834, 54959, 55072, 55288, 55492, 55598, 55795, 55908, 56112, 56225, 56343, 56547, 56756, 56865, 57065, 57178, 57382, 57491, 57691, 57798, 57996, 58110, 58315, 58422, 58620, 58855, 58962, 59160,
59266, 59463, 59696, 59802, 59999, 60232, 60339, 60537, 60644, 60842, 60959, 61167, 61280, 61394, 61505, 61707, 61911, 62116, 62238, 62352, 62565, 62770, 62883, 62989, 63193, 63390, 63501, 63703, 63812, 64012, 64121, 64321, 64560, 64669,
64869, 65108, 65219, 65421, 65527, 65724, 65835, 66037, 66145, 66344, 66581, 66687, 66794, 66905, 67018, 67124, 67326, 67530, 67727, 67925, 68122, 68236, 68441, 68547, 68744, 68850, 69047, 69160, 69364, 69490, 69707, 69980, 70091, 70202,
70313, 70515, 70717, 70919, 71025, 71222, 71455, 71568, 71772, 72019, 72128, 72328, 72435, 72633, 72857, 72968, 73170, 73277, 73475, 73710, 73836, 73942, 74159, 74356, 74463, 74570, 74768, 74966, 75072, 75269, 75382, 75586, 75692, 75889,
75996, 76111, 76309, 76515, 76622, 76820, 76927, 77125, 77236, 77438, 77559, 77666, 77878, 77990, 78188, 78391, 78497, -320, math.MaxInt64, math.MinInt64, math.MaxInt64}
output := intcomp.CompressInt64(testInput, make([]uint64, 0, 100))
input2 := intcomp.UncompressInt64(output, make([]int64, 0, 100))
t.Logf("input len: %d, output len: %d\n", len(testInput), len(output))
if len(input2) != len(testInput) {
t.Fatalf("expected same len")
}
for i, v := range testInput {
if input2[i] != v {
t.Fatalf("i=%d, input2(%d) != input(%d)", i, input2[i], v)
}
}
}
func TestCompressCombinedInt64Multi(t *testing.T) {
var testInputs = [][]int64{{0, 202, -320, math.MaxInt64, math.MinInt64, math.MaxInt64, 529}, {638, 838, 949, 1151, 1257, 1454, 1561, 1759, 1994, 2105, 2307, 2413, 2610, 2716, 2913, 3146, 3253, 3360, 3558, 3665, 3863, 4061, 4168, 4366, 4472, 4578, 4775, 4972, 5079, 5277, 5386,
5586}, {5694, 5801, 6000, 6106, 6304, 6501, 6627, 6844, 6950, 7059, 7256, 7456, 7563, 7672, 7870, 8070, 8309, 8418, 8618, 8857, 8961, 9156, 9269, 9473, 9579, 9776, 9883, 10081, 10187, 10384, 10491, 10689, 10826, 11054, 11180, 11287, 11504,
11610}, {11808, 11915, 12022, 12219, 12417, 12615, 12721, 12918, 13024, 13221, 13328, 13526, 13632, 13735, 13842, 14039, 14233, 14431, 14537, 14734, 14841, 15039, 15145, 15252, 15360, 15557, 15755, 15954, 16093, 16323, 16430, 16628, 16734,
16840}, {17037, 17234, 17467, 17700, 17806, 18003, 18236, 18342, 18539, 18645, 18842, 18948, 19061, 19258, 19462, 19568, 19765, 19871, 20068, 20175, 20373, 20489, 20696, 20802, 20909, 21106, 21304, 21411, 21609, 21715, 21912, 22018, 22215,
22322}, {22428, 22626, 22823, 22929, 23126, 23230, 23336, 23442, 23637, 23834, 24031, 24137, 24243, 24440, 24637, 24744, 24850, 25048, 25245, 25352, 25459, 25657, 25764, 25962, 26160, 26266, 26372, 26569, 26676, 26873, 27071, 27187, 27394,
27500}, {27606, 27712, 27819, 28016, 28213, 28410, 28608, 28726, 28832, 28939, 29046, 29243, 29452, 29650, 29756, 29954, 30062, 30168, 30365, 30562, 30761, 30867, 30973, 31079, 31276, 31383, 31580, 31777, 31900, 32098, 32204, 32310, 32524,
32630}, {32827, 33024, 33221, 33327, 33524, 33631, 33737, 33935, 34132, 34238, 34435, 34542, 34740, 34846, 34949, 35146, 35340, 35447, 35645, 35751, 35948, 36054, 36251, 36358, 36465, 36571, 36678, 36876, 37074, 37271, 37469, 37576, 37774,
37998}, {38104, 38210, 38407, 38604, 38725, 38937, 39044, 39148, 39346, 39452, 39647, 39753, 39950, 40147, 40251, 40357, 40463, 40658, 40765, 40883, 41080, 41277, 41383, 41581, 41790, 41896, 42093, 42290, 42396, 42502, 42608, 42805, 42911,
43108}, {43305, 43502, 43608, 43714, 43911, 44108, 44214, 44411, 44517, 44714, 44820, 44926, 45032, 45141, 45338, 45444, 45641, 45747, 45944, 46051, 46248, 46354, 46554, 46751, 46949, 47146, 47252, 47449, 47562, 47766, 47875, 48075, 48314,
48423}, {48623, 48862, 48968, 49165, 49271, 49468, 49572, 49767, 49880, 49986, 50190, 50387, 50493, 50600, 50797, 50912, 51110, 51316, 51422, 51531, 51731, 51928, 52034, 52231, 52337, 52534, 52640, 52746, 52943, 53140, 53246, 53443, 53676,
53782}, {53979, 54093, 54298, 54404, 54601, 54834, 54959, 55072, 55288, 55492, 55598, 55795, 55908, 56112, 56225, 56343, 56547, 56756, 56865, 57065, 57178, 57382, 57491, 57691, 57798, 57996, 58110, 58315, 58422, 58620, 58855, 58962, 59160,
59266}, {59463, 59696, 59802, 59999, 60232, 60339, 60537, 60644, 60842, 60959, 61167, 61280, 61394, 61505, 61707, 61911, 62116, 62238, 62352, 62565, 62770, 62883, 62989, 63193, 63390, 63501, 63703, 63812, 64012, 64121, 64321, 64560, 64669,
64869}, {65108, 65219, 65421, 65527, 65724, 65835, 66037, 66145, 66344, 66581, 66687, 66794, 66905, 67018, 67124, 67326, 67530, 67727, 67925, 68122, 68236, 68441, 68547, 68744, 68850, 69047, 69160, 69364, 69490, 69707, 69980, 70091, 70202,
70313}, {70515, 70717, 70919, 71025, 71222, 71455, 71568, 71772, 72019, 72128, 72328, 72435, 72633, 72857, 72968, 73170, 73277, 73475, 73710, 73836, 73942, 74159, 74356, 74463, 74570, 74768, 74966, 75072, 75269, 75382, 75586, 75692, 75889,
75996}, {76111, 76309, 76515, 76622, 76820, 76927, 77125, 77236, 77438, 77559, 77666, 77878, 77990, 78188, 78391, 78497, -320, math.MaxInt64, math.MinInt64, math.MaxInt64}}
var testInput []int64
var output []uint64
for _, ti := range testInputs {
output = intcomp.CompressInt64(ti, output)
testInput = append(testInput, ti...)
}
input2 := intcomp.UncompressInt64(output, make([]int64, 0, 100))
t.Logf("input len: %d, output len: %d\n", len(testInput), len(output))
if len(input2) != len(testInput) {
t.Fatalf("expected same len")
}
for i, v := range testInput {
if input2[i] != v {
t.Fatalf("i=%d, input2(%d) != input(%d)", i, input2[i], v)
}
}
}
func TestCompressCombinedInt64_trailing(t *testing.T) {
var testInput = []int64{0, 202, -320, 529, 638, 838, 949, 1151, 1257, 1454, 1561, 1759, 1994, 2105, 2307, 2413, 2610, 2716, 2913, 3146, 3253, 3360, 3558, 3665, 3863, 4061, 4168, 4366, 4472, 4578, 4775, 4972, 5079, 5277, 5386,
5586, 5694, 5801, 6000, 6106, 6304, 6501, 6627, 6844, 6950, 7059, 7256, 7456, 7563, 7672, 7870, 8070, 8309, 8418, 8618, 8857, 8961, 9156, 9269, 9473, 9579, 9776, 9883, 10081, 10187, 10384, 10491, 10689, 10826, 11054, 11180, 11287, 11504,
11610, 11808, 11915, 12022, 12219, 12417, 12615, 12721, 12918, 13024, 13221, 13328, 13526, 13632, 13735, 13842, 14039, 14233, 14431, 14537, 14734, 14841, 15039, 15145, 15252, 15360, 15557, 15755, 15954, 16093, 16323, 16430, 16628, 16734,
16840, 17037, 17234, 17467, 17700, 17806, 18003, 18236, 18342, 18539, 18645, 18842, 18948, 19061, 19258, 19462, 19568, 19765, 19871, 20068, 20175, 20373, 20489, 20696, 20802, 20909, 21106, 21304, 21411, 21609, 21715, 21912, 22018, 22215,
22322, 22428, 22626, 22823, 22929, 23126, 23230, 23336, 23442, 23637, 23834, 24031, 24137, 24243, 24440, 24637, 24744, 24850, 25048, 25245, 25352, 25459, 25657, 25764, 25962, 26160, 26266, 26372, 26569, 26676, 26873, 27071, 27187, 27394,
27500, 27606, 27712, 27819, 28016, 28213, 28410, 28608, 28726, 28832, 28939, 29046, 29243, 29452, 29650, 29756, 29954, 30062, 30168, 30365, 30562, 30761, 30867, 30973, 31079, 31276, 31383, 31580, 31777, 31900, 32098, 32204, 32310, 32524,
32630, 32827, 33024, 33221, 33327, 33524, 33631, 33737, 33935, 34132, 34238, 34435, 34542, 34740, 34846, 34949, 35146, 35340, 35447, 35645, 35751, 35948, 36054, 36251, 36358, 36465, 36571, 36678, 36876, 37074, 37271, 37469, 37576, 37774,
37998, 38104, 38210, 38407, 38604, 38725, 38937, 39044, 39148, 39346, 39452, 39647, 39753, 39950, 40147, 40251, 40357, 40463, 40658, 40765, 40883, 41080, 41277, 41383, 41581, 41790, 41896, 42093, 42290, 42396, 42502, 42608, 42805, 42911,
43108, 43305, 43502, 43608, 43714, 43911, 44108, 44214, 44411, 44517, 44714, 44820, 44926, 45032, 45141, 45338, 45444, 45641, 45747, 45944, 46051, 46248, 46354, 46554, 46751, 46949, 47146, 47252, 47449, 47562, 47766, 47875, 48075, 48314,
48423, 48623, 48862, 48968, 49165, 49271, 49468, 49572, 49767, 49880, 49986, 50190, 50387, 50493, 50600, 50797, 50912, 51110, 51316, 51422, 51531, 51731, 51928, 52034, 52231, 52337, 52534, 52640, 52746, 52943, 53140, 53246, 53443, 53676,
53782, 53979, 54093, 54298, 54404, 54601, 54834, 54959, 55072, 55288, 55492, 55598, 55795, 55908, 56112, 56225, 56343, 56547, 56756, 56865, 57065, 57178, 57382, 57491, 57691, 57798, 57996, 58110, 58315, 58422, 58620, 58855, 58962, 59160,
59266, 59463, 59696, 59802, 59999, 60232, 60339, 60537, 60644, 60842, 60959, 61167, 61280, 61394, 61505, 61707, 61911, 62116, 62238, 62352, 62565, 62770, 62883, 62989, 63193, 63390, 63501, 63703, 63812, 64012, 64121, 64321, 64560, 64669,
64869, 65108, 65219, 65421, 65527, 65724, 65835, 66037, 66145, 66344, 66581, 66687, 66794, 66905, 67018, 67124, 67326, 67530, 67727, 67925, 68122, 68236, 68441, 68547, 68744, 68850, 69047, 69160, 69364, 69490, 69707, 69980, 70091, 70202,
70313, 70515, 70717, 70919, 71025, 71222, 71455, 71568, 71772, 72019, 72128, 72328, 72435, 72633, 72857, 72968, 73170, 73277, 73475, 73710, 73836, 73942, 74159, 74356, 74463, 74570, 74768, 74966, 75072, 75269, 75382, 75586, 75692, 75889,
75996, 76111, 76309, 76515, 76622, 76820, 76927, 77125, 77236, 77438, 77559, 77666, 77878, 77990, 78188, 78391, 78497, -320}
for i := range testInput {
testInput[i] *= 8
}
output := intcomp.CompressInt64(testInput, make([]uint64, 0, 100))
input2 := intcomp.UncompressInt64(output, make([]int64, 0, 100))
t.Logf("input len: %d, output len: %d\n", len(testInput), len(output))
if len(input2) != len(testInput) {
t.Fatalf("expected same len")
}
for i, v := range testInput {
if input2[i] != v {
t.Fatalf("i=%d, input2(%d) != input(%d)", i, input2[i], v)
}
}
}
func TestCompressCombinedUint64(t *testing.T) {
var testInput = []uint64{0, 202, 0, math.MaxUint64, 0, math.MaxUint64, 529, 638, 838, 949, 1151, 1257, 1454, 1561, 1759, 1994, 2105, 2307, 2413, 2610, 2716, 2913, 3146, 3253, 3360, 3558, 3665, 3863, 4061, 4168, 4366, 4472, 4578, 4775, 4972, 5079, 5277, 5386,
5586, 5694, 5801, 6000, 6106, 6304, 6501, 6627, 6844, 6950, 7059, 7256, 7456, 7563, 7672, 7870, 8070, 8309, 8418, 8618, 8857, 8961, 9156, 9269, 9473, 9579, 9776, 9883, 10081, 10187, 10384, 10491, 10689, 10826, 11054, 11180, 11287, 11504,
11610, 11808, 11915, 12022, 12219, 12417, 12615, 12721, 12918, 13024, 13221, 13328, 13526, 13632, 13735, 13842, 14039, 14233, 14431, 14537, 14734, 14841, 15039, 15145, 15252, 15360, 15557, 15755, 15954, 16093, 16323, 16430, 16628, 16734,
16840, 17037, 17234, 17467, 17700, 17806, 18003, 18236, 18342, 18539, 18645, 18842, 18948, 19061, 19258, 19462, 19568, 19765, 19871, 20068, 20175, 20373, 20489, 20696, 20802, 20909, 21106, 21304, 21411, 21609, 21715, 21912, 22018, 22215,
22322, 22428, 22626, 22823, 22929, 23126, 23230, 23336, 23442, 23637, 23834, 24031, 24137, 24243, 24440, 24637, 24744, 24850, 25048, 25245, 25352, 25459, 25657, 25764, 25962, 26160, 26266, 26372, 26569, 26676, 26873, 27071, 27187, 27394,
27500, 27606, 27712, 27819, 28016, 28213, 28410, 28608, 28726, 28832, 28939, 29046, 29243, 29452, 29650, 29756, 29954, 30062, 30168, 30365, 30562, 30761, 30867, 30973, 31079, 31276, 31383, 31580, 31777, 31900, 32098, 32204, 32310, 32524,
32630, 32827, 33024, 33221, 33327, 33524, 33631, 33737, 33935, 34132, 34238, 34435, 34542, 34740, 34846, 34949, 35146, 35340, 35447, 35645, 35751, 35948, 36054, 36251, 36358, 36465, 36571, 36678, 36876, 37074, 37271, 37469, 37576, 37774,
37998, 38104, 38210, 38407, 38604, 38725, 38937, 39044, 39148, 39346, 39452, 39647, 39753, 39950, 40147, 40251, 40357, 40463, 40658, 40765, 40883, 41080, 41277, 41383, 41581, 41790, 41896, 42093, 42290, 42396, 42502, 42608, 42805, 42911,
43108, 43305, 43502, 43608, 43714, 43911, 44108, 44214, 44411, 44517, 44714, 44820, 44926, 45032, 45141, 45338, 45444, 45641, 45747, 45944, 46051, 46248, 46354, 46554, 46751, 46949, 47146, 47252, 47449, 47562, 47766, 47875, 48075, 48314,
48423, 48623, 48862, 48968, 49165, 49271, 49468, 49572, 49767, 49880, 49986, 50190, 50387, 50493, 50600, 50797, 50912, 51110, 51316, 51422, 51531, 51731, 51928, 52034, 52231, 52337, 52534, 52640, 52746, 52943, 53140, 53246, 53443, 53676,
53782, 53979, 54093, 54298, 54404, 54601, 54834, 54959, 55072, 55288, 55492, 55598, 55795, 55908, 56112, 56225, 56343, 56547, 56756, 56865, 57065, 57178, 57382, 57491, 57691, 57798, 57996, 58110, 58315, 58422, 58620, 58855, 58962, 59160,
59266, 59463, 59696, 59802, 59999, 60232, 60339, 60537, 60644, 60842, 60959, 61167, 61280, 61394, 61505, 61707, 61911, 62116, 62238, 62352, 62565, 62770, 62883, 62989, 63193, 63390, 63501, 63703, 63812, 64012, 64121, 64321, 64560, 64669,
64869, 65108, 65219, 65421, 65527, 65724, 65835, 66037, 66145, 66344, 66581, 66687, 66794, 66905, 67018, 67124, 67326, 67530, 67727, 67925, 68122, 68236, 68441, 68547, 68744, 68850, 69047, 69160, 69364, 69490, 69707, 69980, 70091, 70202,
70313, 70515, 70717, 70919, 71025, 71222, 71455, 71568, 71772, 72019, 72128, 72328, 72435, 72633, 72857, 72968, 73170, 73277, 73475, 73710, 73836, 73942, 74159, 74356, 74463, 74570, 74768, 74966, 75072, 75269, 75382, 75586, 75692, 75889,
75996, 76111, 76309, 76515, 76622, 76820, 76927, 77125, 77236, 77438, 77559, 77666, 77878, 77990, 78188, 78391, 78497, 0, math.MaxUint64, 0, math.MaxUint64}
output := intcomp.CompressUint64(testInput, make([]uint64, 0, 100))
input2 := intcomp.UncompressUint64(output, make([]uint64, 0, 100))
t.Logf("input len: %d, output len: %d\n", len(testInput), len(output))
if len(input2) != len(testInput) {
t.Fatalf("expected same len")
}
for i, v := range testInput {
if input2[i] != v {
t.Fatalf("i=%d, input2(%d) != input(%d)", i, input2[i], v)
}
}
}
func TestCompressCombinedUint64Multi(t *testing.T) {
var testInputs = [][]uint64{{0, 202, 0, math.MaxUint64, 0, math.MaxUint64, 529}, {638, 838, 949, 1151, 1257, 1454, 1561, 1759, 1994, 2105, 2307, 2413, 2610, 2716, 2913, 3146, 3253, 3360, 3558, 3665, 3863, 4061, 4168, 4366, 4472, 4578, 4775, 4972, 5079, 5277, 5386,
5586}, {5694, 5801, 6000, 6106, 6304, 6501, 6627, 6844, 6950, 7059, 7256, 7456, 7563, 7672, 7870, 8070, 8309, 8418, 8618, 8857, 8961, 9156, 9269, 9473, 9579, 9776, 9883, 10081, 10187, 10384, 10491, 10689, 10826, 11054, 11180, 11287, 11504,
11610}, {11808, 11915, 12022, 12219, 12417, 12615, 12721, 12918, 13024, 13221, 13328, 13526, 13632, 13735, 13842, 14039, 14233, 14431, 14537, 14734, 14841, 15039, 15145, 15252, 15360, 15557, 15755, 15954, 16093, 16323, 16430, 16628, 16734,
16840}, {17037, 17234, 17467, 17700, 17806, 18003, 18236, 18342, 18539, 18645, 18842, 18948, 19061, 19258, 19462, 19568, 19765, 19871, 20068, 20175, 20373, 20489, 20696, 20802, 20909, 21106, 21304, 21411, 21609, 21715, 21912, 22018, 22215,
22322}, {22428, 22626, 22823, 22929, 23126, 23230, 23336, 23442, 23637, 23834, 24031, 24137, 24243, 24440, 24637, 24744, 24850, 25048, 25245, 25352, 25459, 25657, 25764, 25962, 26160, 26266, 26372, 26569, 26676, 26873, 27071, 27187, 27394,
27500}, {27606, 27712, 27819, 28016, 28213, 28410, 28608, 28726, 28832, 28939, 29046, 29243, 29452, 29650, 29756, 29954, 30062, 30168, 30365, 30562, 30761, 30867, 30973, 31079, 31276, 31383, 31580, 31777, 31900, 32098, 32204, 32310, 32524,
32630}, {32827, 33024, 33221, 33327, 33524, 33631, 33737, 33935, 34132, 34238, 34435, 34542, 34740, 34846, 34949, 35146, 35340, 35447, 35645, 35751, 35948, 36054, 36251, 36358, 36465, 36571, 36678, 36876, 37074, 37271, 37469, 37576, 37774,
37998}, {38104, 38210, 38407, 38604, 38725, 38937, 39044, 39148, 39346, 39452, 39647, 39753, 39950, 40147, 40251, 40357, 40463, 40658, 40765, 40883, 41080, 41277, 41383, 41581, 41790, 41896, 42093, 42290, 42396, 42502, 42608, 42805, 42911,
43108}, {43305, 43502, 43608, 43714, 43911, 44108, 44214, 44411, 44517, 44714, 44820, 44926, 45032, 45141, 45338, 45444, 45641, 45747, 45944, 46051, 46248, 46354, 46554, 46751, 46949, 47146, 47252, 47449, 47562, 47766, 47875, 48075, 48314,
48423}, {48623, 48862, 48968, 49165, 49271, 49468, 49572, 49767, 49880, 49986, 50190, 50387, 50493, 50600, 50797, 50912, 51110, 51316, 51422, 51531, 51731, 51928, 52034, 52231, 52337, 52534, 52640, 52746, 52943, 53140, 53246, 53443, 53676,
53782}, {53979, 54093, 54298, 54404, 54601, 54834, 54959, 55072, 55288, 55492, 55598, 55795, 55908, 56112, 56225, 56343, 56547, 56756, 56865, 57065, 57178, 57382, 57491, 57691, 57798, 57996, 58110, 58315, 58422, 58620, 58855, 58962, 59160,
59266}, {59463, 59696, 59802, 59999, 60232, 60339, 60537, 60644, 60842, 60959, 61167, 61280, 61394, 61505, 61707, 61911, 62116, 62238, 62352, 62565, 62770, 62883, 62989, 63193, 63390, 63501, 63703, 63812, 64012, 64121, 64321, 64560, 64669,
64869}, {65108, 65219, 65421, 65527, 65724, 65835, 66037, 66145, 66344, 66581, 66687, 66794, 66905, 67018, 67124, 67326, 67530, 67727, 67925, 68122, 68236, 68441, 68547, 68744, 68850, 69047, 69160, 69364, 69490, 69707, 69980, 70091, 70202,
70313}, {70515, 70717, 70919, 71025, 71222, 71455, 71568, 71772, 72019, 72128, 72328, 72435, 72633, 72857, 72968, 73170, 73277, 73475, 73710, 73836, 73942, 74159, 74356, 74463, 74570, 74768, 74966, 75072, 75269, 75382, 75586, 75692, 75889,
75996}, {76111, 76309, 76515, 76622, 76820, 76927, 77125, 77236, 77438, 77559, 77666, 77878, 77990, 78188, 78391, 78497, 0, math.MaxUint64, 0, math.MaxUint64}}
var testInput []uint64
var output []uint64
for _, ti := range testInputs {
output = intcomp.CompressUint64(ti, output)
testInput = append(testInput, ti...)
}
input2 := intcomp.UncompressUint64(output, make([]uint64, 0, 100))
t.Logf("input len: %d, output len: %d\n", len(testInput), len(output))
if len(input2) != len(testInput) {
t.Fatalf("expected same len")
}
for i, v := range testInput {
if input2[i] != v {
t.Fatalf("i=%d, input2(%d) != input(%d)", i, input2[i], v)
}
}
}
func TestCompressCombinedUint64_trailing(t *testing.T) {
var testInput = []uint64{0, 202, 0, 529, 638, 838, 949, 1151, 1257, 1454, 1561, 1759, 1994, 2105, 2307, 2413, 2610, 2716, 2913, 3146, 3253, 3360, 3558, 3665, 3863, 4061, 4168, 4366, 4472, 4578, 4775, 4972, 5079, 5277, 5386,
5586, 5694, 5801, 6000, 6106, 6304, 6501, 6627, 6844, 6950, 7059, 7256, 7456, 7563, 7672, 7870, 8070, 8309, 8418, 8618, 8857, 8961, 9156, 9269, 9473, 9579, 9776, 9883, 10081, 10187, 10384, 10491, 10689, 10826, 11054, 11180, 11287, 11504,
11610, 11808, 11915, 12022, 12219, 12417, 12615, 12721, 12918, 13024, 13221, 13328, 13526, 13632, 13735, 13842, 14039, 14233, 14431, 14537, 14734, 14841, 15039, 15145, 15252, 15360, 15557, 15755, 15954, 16093, 16323, 16430, 16628, 16734,
16840, 17037, 17234, 17467, 17700, 17806, 18003, 18236, 18342, 18539, 18645, 18842, 18948, 19061, 19258, 19462, 19568, 19765, 19871, 20068, 20175, 20373, 20489, 20696, 20802, 20909, 21106, 21304, 21411, 21609, 21715, 21912, 22018, 22215,
22322, 22428, 22626, 22823, 22929, 23126, 23230, 23336, 23442, 23637, 23834, 24031, 24137, 24243, 24440, 24637, 24744, 24850, 25048, 25245, 25352, 25459, 25657, 25764, 25962, 26160, 26266, 26372, 26569, 26676, 26873, 27071, 27187, 27394,
27500, 27606, 27712, 27819, 28016, 28213, 28410, 28608, 28726, 28832, 28939, 29046, 29243, 29452, 29650, 29756, 29954, 30062, 30168, 30365, 30562, 30761, 30867, 30973, 31079, 31276, 31383, 31580, 31777, 31900, 32098, 32204, 32310, 32524,
32630, 32827, 33024, 33221, 33327, 33524, 33631, 33737, 33935, 34132, 34238, 34435, 34542, 34740, 34846, 34949, 35146, 35340, 35447, 35645, 35751, 35948, 36054, 36251, 36358, 36465, 36571, 36678, 36876, 37074, 37271, 37469, 37576, 37774,
37998, 38104, 38210, 38407, 38604, 38725, 38937, 39044, 39148, 39346, 39452, 39647, 39753, 39950, 40147, 40251, 40357, 40463, 40658, 40765, 40883, 41080, 41277, 41383, 41581, 41790, 41896, 42093, 42290, 42396, 42502, 42608, 42805, 42911,
43108, 43305, 43502, 43608, 43714, 43911, 44108, 44214, 44411, 44517, 44714, 44820, 44926, 45032, 45141, 45338, 45444, 45641, 45747, 45944, 46051, 46248, 46354, 46554, 46751, 46949, 47146, 47252, 47449, 47562, 47766, 47875, 48075, 48314,
48423, 48623, 48862, 48968, 49165, 49271, 49468, 49572, 49767, 49880, 49986, 50190, 50387, 50493, 50600, 50797, 50912, 51110, 51316, 51422, 51531, 51731, 51928, 52034, 52231, 52337, 52534, 52640, 52746, 52943, 53140, 53246, 53443, 53676,
53782, 53979, 54093, 54298, 54404, 54601, 54834, 54959, 55072, 55288, 55492, 55598, 55795, 55908, 56112, 56225, 56343, 56547, 56756, 56865, 57065, 57178, 57382, 57491, 57691, 57798, 57996, 58110, 58315, 58422, 58620, 58855, 58962, 59160,
59266, 59463, 59696, 59802, 59999, 60232, 60339, 60537, 60644, 60842, 60959, 61167, 61280, 61394, 61505, 61707, 61911, 62116, 62238, 62352, 62565, 62770, 62883, 62989, 63193, 63390, 63501, 63703, 63812, 64012, 64121, 64321, 64560, 64669,
64869, 65108, 65219, 65421, 65527, 65724, 65835, 66037, 66145, 66344, 66581, 66687, 66794, 66905, 67018, 67124, 67326, 67530, 67727, 67925, 68122, 68236, 68441, 68547, 68744, 68850, 69047, 69160, 69364, 69490, 69707, 69980, 70091, 70202,
70313, 70515, 70717, 70919, 71025, 71222, 71455, 71568, 71772, 72019, 72128, 72328, 72435, 72633, 72857, 72968, 73170, 73277, 73475, 73710, 73836, 73942, 74159, 74356, 74463, 74570, 74768, 74966, 75072, 75269, 75382, 75586, 75692, 75889,
75996, 76111, 76309, 76515, 76622, 76820, 76927, 77125, 77236, 77438, 77559, 77666, 77878, 77990, 78188, 78391, 78497, 0}
for i := range testInput {
testInput[i] *= 8
}
output := intcomp.CompressUint64(testInput, make([]uint64, 0, 100))
input2 := intcomp.UncompressUint64(output, make([]uint64, 0, 100))
t.Logf("input len: %d, output len: %d\n", len(testInput), len(output))
if len(input2) != len(testInput) {
t.Fatalf("expected same len")
}
for i, v := range testInput {
if input2[i] != v {
t.Fatalf("i=%d, input2(%d) != input(%d)", i, input2[i], v)
}
}
}
func TestCompressTimestampsInt64(t *testing.T) {
var testInput = []int64{1678299350917000000, 1678299350917000000, 1678299350917000000, 1678299350917000000, 1678299350917000000,
1678299350917000000, 1678299350917000000, 1678299350917000000, 1678299350917000000, 1678299350917000000, 1678299350917000000, 1678299350917000000, 1678299350918000000, 1678299350918000000, 1678299350918000000, 1678299350918000000, 1678299350918000000,
1678299350918000000, 1678299350918000000, 1678299350918000000, 1678299350918000000, 1678299350918000000, 1678299350918000000, 1678299350918000000, 1678299350918000000, 1678299350918000000, 1678299350918000000, 1678299350919000000,
1678299350919000000, 1678299350919000000, 1678299350919000000, 1678299350919000000, 1678299350919000000, 1678299350919000000, 1678299350919000000, 1678299350919000000, 1678299350919000000, 1678299350919000000, 1678299350919000000,
1678299350919000000, 1678299350919000000, 1678299350919000000, 1678299350919000000, 1678299350919000000, 1678299350919000000, 1678299350920000000, 1678299350920000000, 1678299350920000000, 1678299350920000000, 1678299350920000000, 1678299350920000000,
1678299350920000000, 1678299350920000000, 1678299350920000000, 1678299350920000000, 1678299350920000000, 1678299350920000000, 1678299350920000000, 1678299350921000000, 1678299350921000000, 1678299350921000000, 1678299350921000000,
1678299350921000000, 1678299350921000000, 1678299350921000000, 1678299350921000000, 1678299350921000000, 1678299350921000000, 1678299350921000000, 1678299350921000000, 1678299350921000000, 1678299350921000000, 1678299350921000000,
1678299350921000000, 1678299350922000000, 1678299350922000000, 1678299350922000000, 1678299350922000000, 1678299350922000000, 1678299350922000000, 1678299350922000000, 1678299350922000000, 1678299350922000000, 1678299350922000000, 1678299350922000000,
1678299350922000000, 1678299350922000000, 1678299350922000000, 1678299350922000000, 1678299350923000000, 1678299350923000000, 1678299350923000000, 1678299350923000000, 1678299350923000000, 1678299350923000000, 1678299350923000000,
1678299350923000000, 1678299350923000000, 1678299350923000000, 1678299350923000000, 1678299350923000000, 1678299350923000000, 1678299350923000000, 1678299350923000000, 1678299350923000000, 1678299350924000000, 1678299350924000000,
1678299350924000000, 1678299350924000000, 1678299350924000000, 1678299350924000000, 1678299350924000000, 1678299350924000000, 1678299350924000000, 1678299350924000000, 1678299350924000000, 1678299350924000000, 1678299350924000000, 1678299350924000000,
1678299350924000000, 1678299350925000000, 1678299350925000000, 1678299350925000000, 1678299350925000000, 1678299350925000000, 1678299350925000000, 1678299350925000000, 1678299350925000000, 1678299350925000000, 1678299350925000000,
1678299350925000000, 1678299350925000000, 1678299350925000000, 1678299350925000000, 1678299350925000000, 1678299350926000000, 1678299350926000000, 1678299350926000000, 1678299350926000000, 1678299350926000000, 1678299350926000000,
1678299350926000000, 1678299350926000000, 1678299350926000000, 1678299350926000000, 1678299350926000000, 1678299350926000000, 1678299350926000000, 1678299350926000000, 1678299350926000000, 1678299350927000000, 1678299350927000000, 1678299350927000000,
1678299350927000000, 1678299350927000000, 1678299350927000000, 1678299350927000000, 1678299350927000000, 1678299350927000000, 1678299350927000000, 1678299350927000000, 1678299350927000000, 1678299350927000000, 1678299350927000000,
1678299350928000000, 1678299350928000000, 1678299350928000000, 1678299350928000000, 1678299350928000000, 1678299350928000000, 1678299350928000000, 1678299350928000000, 1678299350928000000, 1678299350928000000, 1678299350928000000,
1678299350928000000, 1678299350928000000, 1678299350928000000, 1678299350928000000, 1678299350928000000, 1678299350929000000, 1678299350929000000, 1678299350929000000, 1678299350929000000, 1678299350929000000, 1678299350929000000, 1678299350929000000,
1678299350929000000, 1678299350929000000, 1678299350929000000, 1678299350929000000, 1678299350929000000, 1678299350929000000, 1678299350929000000, 1678299350929000000, 1678299350929000000, 1678299350929000000, 1678299350929000000,
1678299350929000000, 1678299350930000000, 1678299350930000000, 1678299350930000000, 1678299350930000000, 1678299350930000000, 1678299350930000000, 1678299350930000000, 1678299350930000000, 1678299350930000000, 1678299350930000000,
1678299350930000000, 1678299350930000000, 1678299350930000000, 1678299350930000000, 1678299350930000000, 1678299350930000000, 1678299350930000000, 1678299350930000000, 1678299350930000000, 1678299350930000000, 1678299350930000000, 1678299350930000000,
1678299350930000000, 1678299350931000000, 1678299350931000000, 1678299350931000000, 1678299350931000000, 1678299350931000000, 1678299350931000000, 1678299350931000000, 1678299350931000000, 1678299350931000000, 1678299350931000000,
1678299350931000000, 1678299350931000000, 1678299350931000000, 1678299350931000000, 1678299350931000000, 1678299350931000000, 1678299350931000000, 1678299350931000000, 1678299350931000000, 1678299350931000000, 1678299350932000000,
1678299350932000000, 1678299350932000000, 1678299350932000000, 1678299350932000000, 1678299350932000000, 1678299350932000000, 1678299350932000000, 1678299350932000000, 1678299350932000000, 1678299350932000000, 1678299350932000000, 1678299350932000000,
1678299350932000000, 1678299350932000000, 1678299350932000000, 1678299350932000000, 1678299350932000000, 1678299350932000000, 1678299350933000000, 1678299350933000000, 1678299350933000000, 1678299350933000000, 1678299350933000000,
1678299350933000000, 1678299350933000000, 1678299350933000000, 1678299350933000000, 1678299350933000000, 1678299350933000000, 1678299350933000000, 1678299350933000000, 1678299350933000000, 1678299350933000000, 1678299350933000000,
1678299350933000000, 1678299350933000000, 1678299350933000000, 1678299350933000000, 1678299350933000000, 1678299350933000000, 1678299350933000000, 1678299350934000000, 1678299350934000000, 1678299350934000000, 1678299350934000000, 1678299350934000000,
1678299350934000000, 1678299350934000000, 1678299350934000000, 1678299350934000000, 1678299350934000000, 1678299350934000000, 1678299350934000000, 1678299350934000000, 1678299350934000000, 1678299350934000000, 1678299350934000000,
1678299350934000000, 1678299350934000000, 1678299350934000000, 1678299350934000000, 1678299350934000000, 1678299350934000000, 1678299350935000000, 1678299350935000000, 1678299350935000000, 1678299350935000000, 1678299350935000000,
1678299350935000000, 1678299350935000000, 1678299350935000000, 1678299350935000000, 1678299350935000000, 1678299350935000000, 1678299350935000000, 1678299350935000000, 1678299350935000000, 1678299350935000000, 1678299350935000000, 1678299350935000000,
1678299350935000000, 1678299350935000000, 1678299350935000000, 1678299350935000000, 1678299350935000000, 1678299350935000000, 1678299350935000000, 1678299350935000000, 1678299351936000000, 1678299351936000000, 1678299351936000000,
1678299351936000000, 1678299351936000000, 1678299351936000000, 1678299351936000000, 1678299351936000000, 1678299351936000000, 1678299351936000000, 1678299351937000000, 1678299351937000000, 1678299351937000000, 1678299351937000000,
1678299351937000000, 1678299351937000000, 1678299351937000000, 1678299351937000000, 1678299351937000000, 1678299351937000000, 1678299351937000000, 1678299351937000000, 1678299351937000000, 1678299351937000000, 1678299351937000000, 1678299351938000000,
1678299351938000000, 1678299351938000000, 1678299351938000000, 1678299351938000000, 1678299351938000000, 1678299351938000000, 1678299351938000000, 1678299351938000000, 1678299351938000000, 1678299351938000000, 1678299351938000000,
1678299351938000000, 1678299351938000000, 1678299351938000000, 1678299351938000000, 1678299351938000000, 1678299351938000000, 1678299351939000000, 1678299351939000000, 1678299351939000000, 1678299351939000000, 1678299351939000000,
1678299351939000000, 1678299351939000000, 1678299351939000000, 1678299351939000000, 1678299351939000000, 1678299351939000000, 1678299351939000000, 1678299351939000000, 1678299351939000000, 1678299351939000000, 1678299351939000000, 1678299351939000000,
1678299351939000000, 1678299351940000000, 1678299351940000000, 1678299351940000000, 1678299351940000000, 1678299351940000000, 1678299351940000000, 1678299351940000000, 1678299351940000000, 1678299351940000000, 1678299351940000000,
1678299351940000000, 1678299351940000000, 1678299351940000000, 1678299351940000000, 1678299351940000000, 1678299351940000000, 1678299351941000000, 1678299351941000000, 1678299351941000000, 1678299351941000000, 1678299351941000000}
output := intcomp.CompressInt64(testInput, make([]uint64, 0, 100))
input2 := intcomp.UncompressInt64(output, make([]int64, 0, 100))
t.Logf("input len: %d, output len: %d\n", len(testInput), len(output))
if len(input2) != len(testInput) {
t.Fatalf("expected same len")
}
for i, v := range testInput {
if input2[i] != v {
t.Fatalf("i=%d, input2(%d) != input(%d)", i, input2[i], v)
}
}
}