Skip to content

Commit 18ffb99

Browse files
committed
Fix nasa#1890, Improve resource ID branch coverage
1 parent 5e41330 commit 18ffb99

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

modules/resourceid/ut-coverage/test_cfe_resourceid.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ void TestResourceID(void)
163163
UtAssert_True(TestIndex == RefIndex, "ID index after search: id=%lx, expected=%lu, got=%lu",
164164
CFE_ResourceId_ToInteger(Id), (unsigned long)RefIndex, (unsigned long)TestIndex);
165165

166+
/* For valid Id check other invalid inputs */
167+
UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, RefBase, 1, NULL), CFE_ES_BAD_ARGUMENT);
168+
UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, RefBase, 0, &TestIndex), CFE_ES_ERR_RESOURCEID_NOT_VALID);
169+
UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, ~RefBase, 1, &TestIndex), CFE_ES_ERR_RESOURCEID_NOT_VALID);
170+
166171
/* Validate off-nominal inputs */
167172
Id = CFE_ResourceId_FindNext(CFE_RESOURCEID_UNDEFINED, 0, UT_ResourceId_CheckIdSlotUsed);
168173
UtAssert_True(CFE_ResourceId_Equal(Id, CFE_RESOURCEID_UNDEFINED), "CFE_ResourceId_FindNext() bad input: id=%lx",
@@ -171,10 +176,6 @@ void TestResourceID(void)
171176
Id = CFE_ResourceId_FindNext(LastId, 0, NULL);
172177
UtAssert_True(CFE_ResourceId_Equal(Id, CFE_RESOURCEID_UNDEFINED), "CFE_ResourceId_FindNext() bad input: id=%lx",
173178
CFE_ResourceId_ToInteger(Id));
174-
175-
UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, RefBase, 1, NULL), CFE_ES_BAD_ARGUMENT);
176-
UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, RefBase, 0, &TestIndex), CFE_ES_ERR_RESOURCEID_NOT_VALID);
177-
UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, ~RefBase, 1, &TestIndex), CFE_ES_ERR_RESOURCEID_NOT_VALID);
178179
}
179180

180181
void UtTest_Setup(void)

0 commit comments

Comments
 (0)