blob: d94e5db77ff9eb35d3e78f4132d4eeaf13a397cc [file] [log] [blame]
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include "ringbuffer.c"
#include "ringbuffer-test-utils.c"
void test_simple_poll(void)
{
uint8_t in_buf[] = { 'a', 'b', 'c' };
struct rb_test_ctx _ctx;
struct rb_test_ctx *ctx;
struct ringbuffer *rb;
int rc;
ctx = &_ctx;
ringbuffer_test_context_init(ctx);
rb = ringbuffer_init(10);
ctx->rbc = ringbuffer_consumer_register(rb, ringbuffer_poll_append_all,
ctx);
rc = ringbuffer_queue(rb, in_buf, sizeof(in_buf));
assert(!rc);
assert(ctx->count == 1);
assert(ctx->len == sizeof(in_buf));
assert(!memcmp(in_buf, ctx->data, ctx->len));
ringbuffer_fini(rb);
ringbuffer_test_context_fini(ctx);
}
int main(void)
{
test_simple_poll();
return EXIT_SUCCESS;
}