summaryrefslogtreecommitdiff
path: root/FreeRTOS/Test/CMock/timers/timers_1_utest.c
diff options
context:
space:
mode:
Diffstat (limited to 'FreeRTOS/Test/CMock/timers/timers_1_utest.c')
-rw-r--r--FreeRTOS/Test/CMock/timers/timers_1_utest.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/FreeRTOS/Test/CMock/timers/timers_1_utest.c b/FreeRTOS/Test/CMock/timers/timers_1_utest.c
index 04d74e757..e78ce6768 100644
--- a/FreeRTOS/Test/CMock/timers/timers_1_utest.c
+++ b/FreeRTOS/Test/CMock/timers/timers_1_utest.c
@@ -1784,3 +1784,63 @@ void test_timer_function_success_wrap_timer( void )
/* Validations */
TEST_ASSERT_EQUAL( 1, *retVal );
}
+
+void test_xTimerGetStaticBuffer_static( void )
+{
+ TimerHandle_t ret_timer_create;
+ UBaseType_t pvTimerID;
+ StaticTimer_t pxTimerBuffer[ sizeof( StaticTimer_t ) ];
+ StaticTimer_t * pxTimerBufferRet = NULL;
+
+ /* Setup */
+ /* Expectations */
+ /* prvInitialiseNewTimer */
+ /* prvCheckForValidListAndQueue */
+ vListInitialise_ExpectAnyArgs();
+ vListInitialise_ExpectAnyArgs();
+ xQueueGenericCreateStatic_ExpectAnyArgsAndReturn( NULL );
+ /* Back prvInitialiseNewTimer */
+ vListInitialiseItem_ExpectAnyArgs();
+
+ /* API Call */
+ ret_timer_create = xTimerCreateStatic( "ut_timer_task",
+ pdMS_TO_TICKS( 1000 ),
+ pdTRUE,
+ ( void * ) &pvTimerID,
+ xCallback_Test,
+ pxTimerBuffer );
+
+ TEST_ASSERT_EQUAL( pdTRUE, xTimerGetStaticBuffer( ret_timer_create, &pxTimerBufferRet ) );
+ TEST_ASSERT_EQUAL( pxTimerBuffer, pxTimerBufferRet );
+}
+
+void test_xTimerGetStaticBuffer_dynamic( void )
+{
+ TimerHandle_t xTimer = NULL;
+ UBaseType_t pvTimerID = 0;
+ Timer_t pxNewTimer = { 0 };
+ StaticTimer_t * pxTimerBufferRet = NULL;
+
+ pvPortMalloc_ExpectAndReturn( sizeof( Timer_t ), &pxNewTimer );
+
+ /* Setup */
+ /* Expectations */
+ /* prvInitialiseNewTimer */
+ /* prvCheckForValidListAndQueue */
+ vListInitialise_ExpectAnyArgs();
+ vListInitialise_ExpectAnyArgs();
+ xQueueGenericCreateStatic_ExpectAnyArgsAndReturn( NULL );
+ /* Back prvInitialiseNewTimer */
+ vListInitialiseItem_ExpectAnyArgs();
+
+
+ /* API Call */
+ xTimer = xTimerCreate( "ut_timer_task",
+ pdMS_TO_TICKS( 1000 ),
+ pdTRUE,
+ ( void * ) &pvTimerID,
+ xCallback_Test );
+
+ TEST_ASSERT_EQUAL( pdFALSE, xTimerGetStaticBuffer( xTimer, &pxTimerBufferRet ) );
+ TEST_ASSERT_EQUAL( NULL, pxTimerBufferRet );
+}