From 18ffb99d7a473e719eaffc90d9a918facd6eae8d Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Wed, 25 Aug 2021 19:34:30 +0000 Subject: [PATCH] Fix #1890, Improve resource ID branch coverage --- modules/resourceid/ut-coverage/test_cfe_resourceid.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/resourceid/ut-coverage/test_cfe_resourceid.c b/modules/resourceid/ut-coverage/test_cfe_resourceid.c index ec77dd709..0da99bd23 100644 --- a/modules/resourceid/ut-coverage/test_cfe_resourceid.c +++ b/modules/resourceid/ut-coverage/test_cfe_resourceid.c @@ -163,6 +163,11 @@ void TestResourceID(void) UtAssert_True(TestIndex == RefIndex, "ID index after search: id=%lx, expected=%lu, got=%lu", CFE_ResourceId_ToInteger(Id), (unsigned long)RefIndex, (unsigned long)TestIndex); + /* For valid Id check other invalid inputs */ + UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, RefBase, 1, NULL), CFE_ES_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, RefBase, 0, &TestIndex), CFE_ES_ERR_RESOURCEID_NOT_VALID); + UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, ~RefBase, 1, &TestIndex), CFE_ES_ERR_RESOURCEID_NOT_VALID); + /* Validate off-nominal inputs */ Id = CFE_ResourceId_FindNext(CFE_RESOURCEID_UNDEFINED, 0, UT_ResourceId_CheckIdSlotUsed); UtAssert_True(CFE_ResourceId_Equal(Id, CFE_RESOURCEID_UNDEFINED), "CFE_ResourceId_FindNext() bad input: id=%lx", @@ -171,10 +176,6 @@ void TestResourceID(void) Id = CFE_ResourceId_FindNext(LastId, 0, NULL); UtAssert_True(CFE_ResourceId_Equal(Id, CFE_RESOURCEID_UNDEFINED), "CFE_ResourceId_FindNext() bad input: id=%lx", CFE_ResourceId_ToInteger(Id)); - - UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, RefBase, 1, NULL), CFE_ES_BAD_ARGUMENT); - UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, RefBase, 0, &TestIndex), CFE_ES_ERR_RESOURCEID_NOT_VALID); - UtAssert_INT32_EQ(CFE_ResourceId_ToIndex(Id, ~RefBase, 1, &TestIndex), CFE_ES_ERR_RESOURCEID_NOT_VALID); } void UtTest_Setup(void)