Skip to content

Commit abf8aa2

Browse files
xQueueCreateStatic, which for unit testing just create dynamically.
1 parent 857b4dd commit abf8aa2

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

cpputest-for-freertos-lib/src/cpputest_for_freertos_queue.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,17 @@ extern "C" BaseType_t xQueuePeek(QueueHandle_t queue, void * const buffer, TickT
150150
return pdFALSE;
151151
}
152152
}
153+
154+
QueueHandle_t xQueueGenericCreateStatic(const UBaseType_t queueLength,
155+
const UBaseType_t itemSize,
156+
uint8_t * queueStorage,
157+
StaticQueue_t * staticQueue,
158+
const uint8_t queueType)
159+
{
160+
//for unit testing, just going to ignore the provided static queue and allocate
161+
//dynamically.
162+
(void)queueStorage;
163+
(void)staticQueue;
164+
auto queue = xQueueGenericCreate(queueLength, itemSize, queueType);
165+
return queue;
166+
}

cpputest-for-freertos-lib/tests/cpputest_for_freertos_queue_tests.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ TEST(QueueTests, messages_waiting_works_as_expected)
147147
CHECK_EQUAL(2, count);
148148
}
149149

150-
151150
TEST(QueueTests, spaces_available_works_as_expected)
152151
{
153152
const TestEventT event = { 23, 43 };
@@ -167,3 +166,11 @@ TEST(QueueTests, spaces_available_works_as_expected)
167166
count = uxQueueSpacesAvailable(mQueueUnderTest);
168167
CHECK_EQUAL(1, count);
169168
}
169+
170+
TEST(QueueTests, can_create_a_static_queue)
171+
{
172+
static StaticQueue_t staticQueue;
173+
uint8_t queueStorageArea[ 2 * sizeof(TestEventT) ];
174+
mQueueUnderTest = xQueueCreateStatic(2, sizeof(TestEventT), queueStorageArea, &staticQueue);
175+
CHECK_TRUE(mQueueUnderTest != nullptr);
176+
}

0 commit comments

Comments
 (0)