Skip to content

Commit

Permalink
Fix nasa#1254, Remove redundant checks in UT
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed May 16, 2022
1 parent 3b50c59 commit 2a6d659
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
24 changes: 12 additions & 12 deletions src/tests/idmap-api-test/idmap-api-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,34 +203,34 @@ void Test_OS_ConvertToArrayIndex(void)
* Test with nominal values
*/
UtAssert_INT32_EQ(OS_ConvertToArrayIndex(task_id, &TestArrayIndex), OS_SUCCESS);
UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_TASKS, "0 < TestArrayIndex(%lu) <= OS_MAX_TASKS",
UtAssert_True(TestArrayIndex < OS_MAX_TASKS, "TestArrayIndex(%lu) < OS_MAX_TASKS",
(long)TestArrayIndex);

UtAssert_INT32_EQ(OS_ConvertToArrayIndex(queue_id, &TestArrayIndex), OS_SUCCESS);
UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_QUEUES, "0 < TestArrayIndex(%lu) <= OS_MAX_QUEUES",
UtAssert_True(TestArrayIndex < OS_MAX_QUEUES, "TestArrayIndex(%lu) < OS_MAX_QUEUES",
(long)TestArrayIndex);

UtAssert_INT32_EQ(OS_ConvertToArrayIndex(count_sem_id, &TestArrayIndex), OS_SUCCESS);
UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_COUNT_SEMAPHORES,
"0 < TestArrayIndex(%lu) <= OS_MAX_COUNT_SEMAPHORES", (long)TestArrayIndex);
UtAssert_True(TestArrayIndex < OS_MAX_COUNT_SEMAPHORES,
"TestArrayIndex(%lu) < OS_MAX_COUNT_SEMAPHORES", (long)TestArrayIndex);

UtAssert_INT32_EQ(OS_ConvertToArrayIndex(bin_sem_id, &TestArrayIndex), OS_SUCCESS);
UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_BIN_SEMAPHORES,
"0 < TestArrayIndex(%lu) <= OS_MAX_BIN_SEMAPHORES", (long)TestArrayIndex);
UtAssert_True(TestArrayIndex < OS_MAX_BIN_SEMAPHORES,
"TestArrayIndex(%lu) < OS_MAX_BIN_SEMAPHORES", (long)TestArrayIndex);

UtAssert_INT32_EQ(OS_ConvertToArrayIndex(mutex_id1, &TestMutex1Index), OS_SUCCESS);
UtAssert_True(TestMutex1Index >= 0 && TestMutex1Index < OS_MAX_MUTEXES,
"0 < TestMutex1Index(%lu) <= OS_MAX_MUTEXES", (long)TestMutex1Index);
UtAssert_True(TestMutex1Index < OS_MAX_MUTEXES,
"TestMutex1Index(%lu) < OS_MAX_MUTEXES", (long)TestMutex1Index);

UtAssert_INT32_EQ(OS_ConvertToArrayIndex(mutex_id2, &TestMutex2Index), OS_SUCCESS);
UtAssert_True(TestMutex2Index >= 0 && TestMutex2Index < OS_MAX_MUTEXES,
"0 < TestMutex2Index(%lu) <= OS_MAX_MUTEXES", (long)TestMutex2Index);
UtAssert_True(TestMutex2Index < OS_MAX_MUTEXES,
"TestMutex2Index(%lu) < OS_MAX_MUTEXES", (long)TestMutex2Index);
UtAssert_True(TestMutex1Index != TestMutex2Index, "TestMutex1Index(%lu) != TestMutex2Index(%lu)",
(long)TestMutex1Index, (long)TestMutex2Index);

UtAssert_INT32_EQ(OS_ConvertToArrayIndex(time_base_id, &TestArrayIndex), OS_SUCCESS);
UtAssert_True(TestArrayIndex >= 0 && TestArrayIndex < OS_MAX_TIMEBASES,
"0 < TestArrayIndex(%lu) <= OS_MAX_TIMEBASES", (long)TestArrayIndex);
UtAssert_True(TestArrayIndex < OS_MAX_TIMEBASES,
"TestArrayIndex(%lu) < OS_MAX_TIMEBASES", (long)TestArrayIndex);

/*
* Test with extreme cases using invalid inputs and checking
Expand Down
2 changes: 0 additions & 2 deletions src/tests/time-base-api-test/time-base-api-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ void TestTimeBaseApi(void)
(unsigned long)timebase_prop.nominal_interval_time);
UtAssert_True(timebase_prop.freerun_time == 0, "timebase_prop.freerun_time (%lu) == 0",
(unsigned long)timebase_prop.freerun_time);
UtAssert_True(timebase_prop.accuracy >= 0, "timebase_prop.accuracy (%lu) >= 0",
(unsigned long)timebase_prop.accuracy);

/* Test for invalid inputs */
UtAssert_INT32_EQ(OS_TimeBaseGetInfo(OS_OBJECT_ID_UNDEFINED, &timebase_prop), OS_ERR_INVALID_ID);
Expand Down

0 comments on commit 2a6d659

Please sign in to comment.