From bc489e39a8036bd8cc70569ac8e31ec257d68747 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 6 Jan 2010 10:30:01 +0000 Subject: Coverage 100% for modified queues. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1505 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- test/testqueues.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/testqueues.c b/test/testqueues.c index c07e8aee3..6c16cce63 100644 --- a/test/testqueues.c +++ b/test/testqueues.c @@ -112,13 +112,24 @@ static void queues1_execute(void) { test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size"); test_assert(7, chIQIsEmpty(&iq), "still full"); + /* Queue filling again */ + for (i = 0; i < TEST_QUEUES_SIZE; i++) + chIQPutI(&iq, 'A' + i); + + /* Partial reads */ + n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); + test_assert(8, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); + n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); + test_assert(9, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); + test_assert(10, chIQIsEmpty(&iq), "still full"); + /* Testing reset */ chIQPutI(&iq, 0); chIQResetI(&iq); - test_assert(8, chIQIsEmpty(&iq), "still full"); + test_assert(11, chIQIsEmpty(&iq), "still full"); /* Timeout */ - test_assert(9, chIQGetTimeout(&iq, 10) == Q_TIMEOUT, "wrong timeout return"); + test_assert(12, chIQGetTimeout(&iq, 10) == Q_TIMEOUT, "wrong timeout return"); } const struct testcase testqueues1 = { @@ -167,18 +178,22 @@ static void queues2_execute(void) { /* Writing the whole thing */ n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE * 2, TIME_IMMEDIATE); - test_assert(6, n == TEST_QUEUES_SIZE,"wrong returned size"); + test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size"); test_assert(7, chOQIsFull(&oq), "not full"); /* Testing reset */ chOQResetI(&oq); test_assert(8, chOQIsEmpty(&oq), "still full"); + /* Partial writes */ + n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); + test_assert(9, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); + n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); + test_assert(10, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); + test_assert(11, chOQIsFull(&oq), "not full"); + /* Timeout */ - for (i = 0; i < TEST_QUEUES_SIZE; i++) - chOQPut(&oq, 'A' + i); - test_assert(9, chOQIsFull(&oq), "still has space"); - test_assert(10, chOQPutTimeout(&oq, 0, 10) == Q_TIMEOUT, "wrong timeout return"); + test_assert(12, chOQPutTimeout(&oq, 0, 10) == Q_TIMEOUT, "wrong timeout return"); } const struct testcase testqueues2 = { -- cgit v1.2.3