Skip to content

Commit

Permalink
tests/unittests: chunked_ringbuffer: add test for half-written chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Dec 12, 2024
1 parent d39c769 commit 3d16d4b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sys/include/chunked_ringbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ bool crb_end_chunk(chunk_ringbuf_t *rb, bool valid);
/**
* @brief Start a new chunk on the ringbuffer
*
* If an unfinished chunk already exists, it will be discarded.
*
* @note This function is expected to be called in ISR context / with
* interrupts disabled.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ static void test_crb_add_and_consume(void)

crb_init(&cb, buffer, sizeof(buffer));

/* add a chunk but don't finish it */
crb_start_chunk(&cb);
crb_add_byte(&cb, 1);
crb_add_byte(&cb, 2);
crb_add_byte(&cb, 3);

TEST_ASSERT(crb_add_chunk(&cb, "one", 4));
TEST_ASSERT(crb_add_chunk(&cb, "two", 4));
TEST_ASSERT(crb_add_chunk(&cb, "three", 6));
Expand Down

0 comments on commit 3d16d4b

Please sign in to comment.