Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions unit-test/cf_cfdp_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,18 +534,45 @@ void Test_CF_CFDP_RecvInit(void)

void Test_CF_CFDP_CopyStringFromLV(void)
{
/* Test case for:
* int CF_CFDP_CopyStringFromLV(char *buf, size_t buf_maxsz, const CF_Logical_Lv_t *src_lv)
*/
char buf[20];
const char refstr[] = "refstr";
CF_Logical_Lv_t input;

input.data_ptr = refstr;
input.length = sizeof(refstr) - 1;

/* nominal call */
UtAssert_INT32_EQ(CF_CFDP_CopyStringFromLV(buf, sizeof(buf), &input), input.length);
/* Nominal case */
UtAssert_INT32_EQ(
CF_CFDP_CopyStringFromLV(buf, sizeof(buf), &input),
input.length);

/* Buffer too small */
UtAssert_INT32_EQ(
CF_CFDP_CopyStringFromLV(buf, 3, &input),
CF_ERROR);

/* NULL source LV */
UtAssert_INT32_EQ(
CF_CFDP_CopyStringFromLV(buf, sizeof(buf), NULL),
CF_ERROR);

/* NULL destination buffer */
UtAssert_INT32_EQ(
CF_CFDP_CopyStringFromLV(NULL, sizeof(buf), &input),
CF_ERROR);

/* Zero buffer size */
UtAssert_INT32_EQ(
CF_CFDP_CopyStringFromLV(buf, 0, &input),
CF_ERROR);

/* NULL data pointer */
input.data_ptr = NULL;
input.length = 5;

UtAssert_INT32_EQ(
CF_CFDP_CopyStringFromLV(buf, sizeof(buf), &input),
CF_ERROR);
}

void Test_CF_CFDP_ConstructPduHeader(void)
Expand Down
Loading