16 #include "CUnit/Basic.h"
17 #include "CUnit/CUnit.h"
41 if ( size != expected_size )
42 printf(
"Expected: %d\nObtained: %d\n", expected_size, size);
44 CU_ASSERT_EQUAL(size, expected_size);
58 if ( size != expected_size )
60 printf(
"Expected: %d\nObtained: %d\n", expected_size, size);
62 CU_ASSERT_EQUAL(size,expected_size);
76 if ( size != expected_size )
78 printf(
"Expected: %d\nObtained: %d\n", expected_size, size);
80 CU_ASSERT_EQUAL(size,expected_size);
94 if ( size != expected_size )
96 printf(
"Expected: %d\nObtained: %d\n", expected_size, size);
98 CU_ASSERT_EQUAL(size,expected_size);
181 size_t size_in, size_out;
184 CU_ASSERT_EQUAL(i64_in, i64_out);
185 CU_ASSERT_EQUAL(size_in, size_out);
192 size_t size_in, size_out;
195 CU_ASSERT_EQUAL(i64_in, i64_out);
196 CU_ASSERT_EQUAL(size_in, size_out);
205 for ( i = 0; i < 1024; i += 63 )
219 for ( i = 1; i < 1024; i += 31 )
253 CU_pSuite suite = CU_add_suite(
"varint", NULL, NULL);
static void do_test_s32_varint(int32_t nr, int expected_size, char *expected_res)
static void do_test_u32_varint(uint32_t nr, int expected_size, char *expected_res)
static void test_zigzag(void)
static void test_varint_roundtrip(void)
static void test_varint(void)
static void do_test_u64_varint(uint64_t nr, int expected_size, char *expected_res)
static void do_test_u64_roundtrip(uint64_t i64_in)
static void do_test_s64_roundtrip(int64_t i64_in)
void varint_suite_setup(void)
static void do_test_s64_varint(int64_t nr, int expected_size, char *expected_res)
#define PG_ADD_TEST(suite, testfunc)
#define ASSERT_STRING_EQUAL(o, e)
char * hexbytes_from_bytes(const uint8_t *bytes, size_t size)
Datum buffer(PG_FUNCTION_ARGS)
int64_t unzigzag64(uint64_t val)
int32_t unzigzag32(uint32_t val)
size_t varint_s32_encode_buf(int32_t val, uint8_t *buf)
size_t varint_s64_encode_buf(int64_t val, uint8_t *buf)
int8_t unzigzag8(uint8_t val)
size_t varint_u64_encode_buf(uint64_t val, uint8_t *buf)
int64_t varint_s64_decode(const uint8_t *the_start, const uint8_t *the_end, size_t *size)
uint64_t zigzag64(int64_t val)
uint64_t varint_u64_decode(const uint8_t *the_start, const uint8_t *the_end, size_t *size)
uint32_t zigzag32(int32_t val)
uint8_t zigzag8(int8_t val)
size_t varint_u32_encode_buf(uint32_t val, uint8_t *buf)