@@ -416,6 +416,37 @@ void UT_os_geterrorname_test(void)
416
416
UtAssert_StrCmp (errNames [2 ], "OS_ERR_NO_FREE_IDS" , "%s == %s" , errNames [2 ], "OS_ERR_NO_FREE_IDS" );
417
417
}
418
418
419
+ /*--------------------------------------------------------------------------------*
420
+ ** OS_StatusToString test helper function to avoid repeating logic
421
+ **--------------------------------------------------------------------------------*/
422
+ void UT_os_statustostring_test_helper (osal_status_t status )
423
+ {
424
+ os_status_string_t status_string ;
425
+ char * rtn_addr ;
426
+ char expected [OS_STATUS_STRING_LENGTH + 1 ];
427
+
428
+ /* Used oversized string to test for truncation */
429
+ snprintf (expected , sizeof (expected ) - 1 , "%ld" , OS_StatusToInteger (status ));
430
+ rtn_addr = OS_StatusToString (status , & status_string );
431
+ UtAssert_ADDRESS_EQ (rtn_addr , status_string );
432
+ UtAssert_STRINGBUF_EQ (status_string , sizeof (status_string ), expected , sizeof (expected ));
433
+ }
434
+
435
+ /*--------------------------------------------------------------------------------*
436
+ ** Functional OS_StatusToString test
437
+ **--------------------------------------------------------------------------------*/
438
+ void UT_os_statustostring_test (void )
439
+ {
440
+ /* NULL test */
441
+ UtAssert_ADDRESS_EQ (OS_StatusToString (OS_SUCCESS , NULL ), NULL );
442
+
443
+ /* Status value tests */
444
+ UT_os_statustostring_test_helper (OS_SUCCESS );
445
+ UT_os_statustostring_test_helper (OS_ERROR );
446
+ UT_os_statustostring_test_helper (OSAL_STATUS_C (INT32_MAX ));
447
+ UT_os_statustostring_test_helper (OSAL_STATUS_C (INT32_MIN ));
448
+ }
449
+
419
450
/*--------------------------------------------------------------------------------*
420
451
** Syntax: int32 OS_HeapGetInfo(OS_heap_prop_t *heap_prop)
421
452
** Purpose: Returns current info on the heap
0 commit comments