2013-01-14 21:10:18 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <assert.h>
|
2013-02-02 15:31:30 +00:00
|
|
|
#include <tokudb_vlq.h>
|
2013-01-14 21:10:18 +00:00
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
uint32_t n;
|
|
|
|
unsigned char b[5];
|
|
|
|
size_t out_s, in_s;
|
|
|
|
|
|
|
|
printf("%u\n", 0);
|
|
|
|
for (uint32_t v = 0; v < (1<<7); v++) {
|
2013-02-02 15:31:30 +00:00
|
|
|
out_s = tokudb::vlq_encode_uint32(v, b, sizeof b);
|
2013-01-14 21:10:18 +00:00
|
|
|
assert(out_s == 1);
|
2013-02-02 15:31:30 +00:00
|
|
|
in_s = tokudb::vlq_decode_uint32(&n, b, out_s);
|
2013-01-14 21:10:18 +00:00
|
|
|
assert(in_s == 1 && n == v);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("%u\n", 1<<7);
|
|
|
|
for (uint32_t v = (1<<7); v < (1<<14); v++) {
|
2013-02-02 15:31:30 +00:00
|
|
|
out_s = tokudb::vlq_encode_uint32(v, b, sizeof b);
|
2013-01-14 21:10:18 +00:00
|
|
|
assert(out_s == 2);
|
2013-02-02 15:31:30 +00:00
|
|
|
in_s = tokudb::vlq_decode_uint32(&n, b, out_s);
|
2013-01-14 21:10:18 +00:00
|
|
|
assert(in_s == 2 && n == v);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("%u\n", 1<<14);
|
|
|
|
for (uint32_t v = (1<<14); v < (1<<21); v++) {
|
2013-02-02 15:31:30 +00:00
|
|
|
out_s = tokudb::vlq_encode_uint32(v, b, sizeof b);
|
2013-01-14 21:10:18 +00:00
|
|
|
assert(out_s == 3);
|
2013-02-02 15:31:30 +00:00
|
|
|
in_s = tokudb::vlq_decode_uint32(&n, b, out_s);
|
2013-01-14 21:10:18 +00:00
|
|
|
assert(in_s == 3 && n == v);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("%u\n", 1<<21);
|
|
|
|
for (uint32_t v = (1<<21); v < (1<<28); v++) {
|
2013-02-02 15:31:30 +00:00
|
|
|
out_s = tokudb::vlq_encode_uint32(v, b, sizeof b);
|
2013-01-14 21:10:18 +00:00
|
|
|
assert(out_s == 4);
|
2013-02-02 15:31:30 +00:00
|
|
|
in_s = tokudb::vlq_decode_uint32(&n, b, out_s);
|
2013-01-14 21:10:18 +00:00
|
|
|
assert(in_s == 4 && n == v);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("%u\n", 1<<28);
|
|
|
|
for (uint32_t v = (1<<28); v != 0; v++) {
|
2013-02-02 15:31:30 +00:00
|
|
|
out_s = tokudb::vlq_encode_uint32(v, b, sizeof b);
|
2013-01-14 21:10:18 +00:00
|
|
|
assert(out_s == 5);
|
2013-02-02 15:31:30 +00:00
|
|
|
in_s = tokudb::vlq_decode_uint32(&n, b, out_s);
|
2013-01-14 21:10:18 +00:00
|
|
|
assert(in_s == 5 && n == v);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|