/* Copyright (c) 2007-2018 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "buffer.h"
static void test_buffer_random(void)
{
unsigned int i, shadowbuf_size;
bool zero;
for (i = 0; i < BUF_TEST_SIZE; i++)
shadowbuf_size = 0;
for (i = 0; i < BUF_TEST_COUNT; i++) {
}
switch (test) {
case 0:
if (!zero) {
} else {
}
break;
case 1:
if (!zero) {
} else {
}
shadowbuf_size += size;
break;
case 2:
if (!zero) {
} else {
}
if (pos < shadowbuf_size)
shadowbuf_size += size;
else
break;
case 3:
if (pos < shadowbuf_size) {
shadowbuf_size -= size;
}
break;
case 4:
if (shadowbuf_size <= 1)
break;
break;
case 5:
break;
}
break;
}
if (i == BUF_TEST_COUNT)
else {
}
buffer_free(&buf);
}
static void test_buffer_write(void)
{
test_begin("buffer_write");
test_end();
}
static void test_buffer_set_used_size(void)
{
test_begin("buffer_set_used_size");
test_end();
}
#if 0
/* this code is left here to produce the output found in
* buffer.h should it be needed for debugging purposes */
#include "str.h"
#include "hex-binary.h"
{
for (int j = 0; j < 8; j++) {
else
}
}
}
static void test_foo(void)
{
for (int i = 1; i <= 24; i++) {
buffer_set_used_size(buf, 0);
printf("%2d bits: %24s %s\n", i,
}
}
#endif
static void test_buffer_truncate_bits(void)
{
test_begin("buffer_test_truncate_bits");
struct {
} test_cases[] = {
{ { "\xff\xff\xff", 3, {0} }, 0, { "", 0, {0} } },
{ { "\xff\xff\xff", 3, {0} }, 1, { "\x01", 1, {0} } },
{ { "\xff\xff\xff", 3, {0} }, 2, { "\x03", 1, {0} } },
{ { "\xff\xff\xff", 3, {0} }, 3, { "\x07", 1, {0} } },
{ { "\xff\xff\xff", 3, {0} }, 4, { "\x0f", 1, {0} } },
{ { "\xff\xff\xff", 3, {0} }, 5, { "\x1f", 1, {0} } },
{ { "\xff\xff\xff", 3, {0} }, 6, { "\x3f", 1, {0} } },
{ { "\xff\xff\xff", 3, {0} }, 7, { "\x7f", 1, {0} } },
{ { "\xff\xff\xff", 3, {0} }, 8, { "\xff", 1, {0} } },
{ { "\xff\xff\xff", 3, {0} }, 9, { "\x01\xff", 2, {0} } },
{ { "\xff\xff\xff", 3, {0} }, 10, { "\x03\xff", 2, {0} } },
{ { "\xff\xff\xff", 3, {0} }, 11, { "\x07\xff", 2, {0} } },
{ { "\xff\xff\xff", 3, {0} }, 12, { "\x0f\xff", 2, {0} } },
{ { "\xff\xff\xff", 3, {0} }, 13, { "\x1f\xff", 2, {0} } },
{ { "\xff\xff\xff", 3, {0} }, 14, { "\x3f\xff", 2, {0} } },
{ { "\xff\xff\xff", 3, {0} }, 15, { "\x7f\xff", 2, {0} } },
{ { "0123456789", 10, {0} }, 16, { "01", 2, {0} } },
{ { "0123456789", 10, {0} }, 24, { "012", 3, {0} } },
{ { "0123456789", 10, {0} }, 32, { "0123", 4, {0} } },
{ { "0123456789", 10, {0} }, 40, { "01234", 5, {0} } },
{ { "0123456789", 10, {0} }, 48, { "012345", 6, {0} } },
{ { "0123456789", 10, {0} }, 56, { "0123456", 7, {0} } },
{ { "0123456789", 10, {0} }, 64, { "01234567", 8, {0} } },
{ { "0123456789", 10, {0} }, 72, { "012345678", 9, {0} } },
{ { "0123456789", 10, {0} }, 80, { "0123456789", 10, {0} } },
{ { "\x58\x11\xed\x02\x4d\x87\x4a\xe2\x5c\xb2\xfa\x69\xf0\xa9\x46\x2e\x04\xca\x5d\x82", 20, {0} },
13,
{ "\x0b\x02", 2, {0} }
},
/* special test cases for auth policy */
{ { "\x34\x40\xc8\xc9\x3a\xb6\xe7\xc4\x3f\xc1\xc3\x4d\xd5\x56\xa3\xea\xfb\x5a\x33\x57\xac\x11\x39\x2c\x71\xcb\xee\xbb\xc8\x66\x2f\x64", 32, {0} },
12,
{ "\x03\x44", 2, {0} }
},
{ { "\x49\xe5\x8a\x88\x76\xd3\x25\x68\xc9\x89\x4a\xe0\x64\xe4\x04\xf4\xf9\x13\xec\x88\x97\x47\x30\x7f\x3f\xcd\x8f\x74\x4f\x40\xd1\x25", 32, {0} },
12,
{ "\x04\x9e", 2, {0} }
},
{ { "\x08\x3c\xdc\x14\x61\x80\x1c\xe8\x43\x81\x98\xfa\xc0\x64\x04\x7a\xa2\x73\x25\x6e\xe6\x4b\x85\x42\xd0\xe2\x78\xd7\x91\xb4\x89\x3f", 32, {0} },
12,
{ "\x00\x83", 2, {0} }
},
};
buffer_set_used_size(buf, 0);
}
test_end();
}
void test_buffer(void)
{
}