1 
2 #include <stdlib.h>
3 #include <stdint.h>
4 #include <stdio.h>
5 
6 #include "ringbuffer.c"
7 #include "ringbuffer-test-utils.c"
8 
9 void test_simple_poll(void)
10 {
11 	uint8_t in_buf[] = { 'a', 'b', 'c' };
12 	struct rb_test_ctx _ctx, *ctx;
13 	struct ringbuffer *rb;
14 	int rc;
15 
16 	ctx = &_ctx;
17 	ringbuffer_test_context_init(ctx);
18 
19 	rb = ringbuffer_init(10);
20 	ctx->rbc = ringbuffer_consumer_register(rb,
21 			ringbuffer_poll_append_all, ctx);
22 
23 	rc = ringbuffer_queue(rb, in_buf, sizeof(in_buf));
24 	assert(!rc);
25 
26 	assert(ctx->count == 1);
27 	assert(ctx->len == sizeof(in_buf));
28 	assert(!memcmp(in_buf, ctx->data, ctx->len));
29 
30 	ringbuffer_fini(rb);
31 	ringbuffer_test_context_fini(ctx);
32 }
33 
34 int main(void)
35 {
36 	test_simple_poll();
37 	return EXIT_SUCCESS;
38 }
39