blob: a4be6246f47d74193ec8d76bcd9b7f1f02c73947 [file] [log] [blame]
Jeremy Kerrc9775ce2017-02-07 16:25:34 +08001
2#include <stdlib.h>
3#include <stdint.h>
4#include <stdio.h>
5
6#include "ringbuffer.c"
7#include "ringbuffer-test-utils.c"
8
9void test_read_commit(void)
10{
11 uint8_t *out_buf, in_buf[] = { 'a', 'b', 'c', };
12 struct ringbuffer_consumer *rbc;
13 struct ringbuffer *rb;
14 size_t len;
15
16 rb = ringbuffer_init(10);
17 rbc = ringbuffer_consumer_register(rb, ringbuffer_poll_nop, NULL);
18
19 ringbuffer_queue(rb, in_buf, sizeof(in_buf));
20 len = ringbuffer_dequeue_peek(rbc, 0, &out_buf);
21
22 ringbuffer_dequeue_commit(rbc, len);
23 len = ringbuffer_dequeue_peek(rbc, 0, &out_buf);
24 assert(len == 0);
25
26 ringbuffer_fini(rb);
27}
28
29int main(void)
30{
31 test_read_commit();
32 return EXIT_SUCCESS;
33}