| |
| #include <stdlib.h> |
| #include <stdint.h> |
| #include <stdio.h> |
| |
| #include "ringbuffer.c" |
| #include "ringbuffer-test-utils.c" |
| |
| void test_read_commit(void) |
| { |
| uint8_t *out_buf; |
| uint8_t in_buf[] = { |
| 'a', |
| 'b', |
| 'c', |
| }; |
| struct ringbuffer_consumer *rbc; |
| struct ringbuffer *rb; |
| size_t len; |
| |
| rb = ringbuffer_init(10); |
| rbc = ringbuffer_consumer_register(rb, ringbuffer_poll_nop, NULL); |
| |
| ringbuffer_queue(rb, in_buf, sizeof(in_buf)); |
| len = ringbuffer_dequeue_peek(rbc, 0, &out_buf); |
| |
| ringbuffer_dequeue_commit(rbc, len); |
| len = ringbuffer_dequeue_peek(rbc, 0, &out_buf); |
| assert(len == 0); |
| |
| ringbuffer_fini(rb); |
| } |
| |
| int main(void) |
| { |
| test_read_commit(); |
| return EXIT_SUCCESS; |
| } |