From 6219918e020c6255ab854306478a2ee4876cc8c7 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 15 May 2022 15:26:13 +0200 Subject: shared/ring: ring_contig --- src/kernel/tests/util.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/kernel') diff --git a/src/kernel/tests/util.c b/src/kernel/tests/util.c index cf16b75..b7123b4 100644 --- a/src/kernel/tests/util.c +++ b/src/kernel/tests/util.c @@ -32,12 +32,23 @@ TEST(strcmp) { } TEST(ring) { - char backbuf[16]; + char backbuf[16], cmpbuf[16]; size_t num_read = 0, num_written = 0; uint8_t c; ring_t r = {backbuf, 16, 0, 0}; + // test aliasing + for (size_t i = 0; i < 16; i++) { + TEST_COND(ring_size(&r) == 0); + ring_put(&r, "11 bytes...", 11); + TEST_COND(ring_size(&r) == 11); + + memset(cmpbuf, 0, sizeof cmpbuf); + TEST_COND(ring_get(&r, cmpbuf, 16) == 11); + TEST_COND(memcmp(cmpbuf, "11 bytes...", 11) == 0); + } + TEST_COND(ring_size(&r) == 0); for (size_t i = 0; i < 7; i++) ring_put1b(&r, num_written++); -- cgit v1.2.3