test-numpack.c revision 5a580c3a38ced62d4bcc95b8ac7c4f2935b5d294
/* Copyright (c) 2013 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "buffer.h"
#include "numpack.h"
#include <stdlib.h>
static struct test {
unsigned int output_size;
} tests[] = {
{ 0xffffffff, { 0xff, 0xff, 0xff, 0xff, 0xf }, 5 },
{ 0, { 0 }, 1 },
{ 0x7f, { 0x7f }, 1 },
{ 0x80, { 0x80, 1 }, 2 },
{ 0x81, { 0x81, 1 }, 2 },
{ 0xdeadbeefcafe, { 0xfe, 0x95, 0xbf, 0xf7, 0xdb, 0xd5, 0x37 }, 7 },
{ 0xffffffffffffffff, { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 1 }, 10 },
{ 0xfffffffe, { 0xfe, 0xff, 0xff, 0xff, 0xf }, 5 },
};
void test_numpack(void)
{
unsigned int i;
test_begin("numpack");
for (i = 0; i < N_ELEMENTS(tests); i++) {
buffer_set_used_size(buf, 0);
tests[i].output_size) == 0);
}
test_end();
}