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 
test_simple_poll(void)9 void test_simple_poll(void)
10 {
11 	uint8_t in_buf[] = { 'a', 'b', 'c' };
12 	struct rb_test_ctx _ctx;
13 	struct rb_test_ctx *ctx;
14 	struct ringbuffer *rb;
15 	int rc;
16 
17 	ctx = &_ctx;
18 	ringbuffer_test_context_init(ctx);
19 
20 	rb = ringbuffer_init(10);
21 	ctx->rbc = ringbuffer_consumer_register(rb, ringbuffer_poll_append_all,
22 						ctx);
23 
24 	rc = ringbuffer_queue(rb, in_buf, sizeof(in_buf));
25 	assert(!rc);
26 
27 	assert(ctx->count == 1);
28 	assert(ctx->len == sizeof(in_buf));
29 	assert(!memcmp(in_buf, ctx->data, ctx->len));
30 
31 	ringbuffer_fini(rb);
32 	ringbuffer_test_context_fini(ctx);
33 }
34 
main(void)35 int main(void)
36 {
37 	test_simple_poll();
38 	return EXIT_SUCCESS;
39 }
40