blob: 96018c4203da4c509b77a5aa44ab53d6702bac59 [file] [log] [blame]
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include "ringbuffer.c"
#include "ringbuffer-test-utils.c"
void test_contained_read(void)
{
uint8_t *out_buf;
uint8_t in_buf[] = { 'a', 'b', 'c' };
struct ringbuffer_consumer *rbc;
struct ringbuffer *rb;
size_t len;
int rc;
rb = ringbuffer_init(10);
rbc = ringbuffer_consumer_register(rb, ringbuffer_poll_nop, NULL);
rc = ringbuffer_queue(rb, in_buf, sizeof(in_buf));
assert(!rc);
len = ringbuffer_dequeue_peek(rbc, 0, &out_buf);
assert(len == sizeof(in_buf));
assert(!memcmp(in_buf, out_buf, sizeof(in_buf)));
ringbuffer_fini(rb);
}
int main(void)
{
test_contained_read();
return EXIT_SUCCESS;
}