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_read_commit(void)9 void test_read_commit(void)
10 {
11 uint8_t *out_buf;
12 uint8_t in_buf[] = {
13 'a',
14 'b',
15 'c',
16 };
17 struct ringbuffer_consumer *rbc;
18 struct ringbuffer *rb;
19 size_t len;
20
21 rb = ringbuffer_init(10);
22 rbc = ringbuffer_consumer_register(rb, ringbuffer_poll_nop, NULL);
23
24 ringbuffer_queue(rb, in_buf, sizeof(in_buf));
25 len = ringbuffer_dequeue_peek(rbc, 0, &out_buf);
26
27 ringbuffer_dequeue_commit(rbc, len);
28 len = ringbuffer_dequeue_peek(rbc, 0, &out_buf);
29 assert(len == 0);
30
31 ringbuffer_fini(rb);
32 }
33
main(void)34 int main(void)
35 {
36 test_read_commit();
37 return EXIT_SUCCESS;
38 }
39