summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-09-18 13:35:26 +0700
committerhathach <[email protected]>2021-09-18 13:35:26 +0700
commit3333703d257b4b2a37f543a65ea4a6e2db777fdb (patch)
treefb37112e82f7f64857473d8346f32c763bd67ec9 /test
parent82618d2d5f15d0f8dd9631dec3807964a1281782 (diff)
parent90465299b42facff3c815d97950066706dbbd74a (diff)
Merge branch 'master' into zhangslice-master
Diffstat (limited to 'test')
-rw-r--r--test/test/test_fifo.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/test/test_fifo.c b/test/test/test_fifo.c
index f9bfc5f03..0a5f4d3b9 100644
--- a/test/test/test_fifo.c
+++ b/test/test/test_fifo.c
@@ -292,3 +292,27 @@ void test_full(void)
// write info
}
+
+void test_rd_idx_wrap()
+{
+ tu_fifo_t ff10;
+ uint8_t buf[10];
+ uint8_t dst[10];
+
+ tu_fifo_config(&ff10, buf, 10, 1, 1);
+
+ uint16_t n;
+
+ ff10.wr_idx = 6;
+ ff10.rd_idx = 15;
+
+ n = tu_fifo_read_n(&ff10, dst, 4);
+ TEST_ASSERT_EQUAL(n, 4);
+ TEST_ASSERT_EQUAL(ff10.rd_idx, 0);
+ n = tu_fifo_read_n(&ff10, dst, 4);
+ TEST_ASSERT_EQUAL(n, 4);
+ TEST_ASSERT_EQUAL(ff10.rd_idx, 4);
+ n = tu_fifo_read_n(&ff10, dst, 4);
+ TEST_ASSERT_EQUAL(n, 2);
+ TEST_ASSERT_EQUAL(ff10.rd_idx, 6);
+} \ No newline at end of file