Add timestamp snprintf. Fix bacapp snprintf to account for string size zero behavior of snprintf.
This commit is contained in:
@@ -520,6 +520,8 @@ static void testDatetimeCodec(void)
|
||||
int apdu_len;
|
||||
int test_len;
|
||||
int null_len;
|
||||
int str_len;
|
||||
char str[64];
|
||||
int diff;
|
||||
bool status;
|
||||
|
||||
@@ -541,6 +543,20 @@ static void testDatetimeCodec(void)
|
||||
zassert_true(apdu_len > 0, NULL);
|
||||
diff = datetime_compare(&datetimeOut, &datetimeIn);
|
||||
zassert_equal(diff, 0, NULL);
|
||||
/* test time stringify */
|
||||
str_len = datetime_time_to_ascii(&datetimeIn.time, str, sizeof(str));
|
||||
zassert_true(str_len > 0, NULL);
|
||||
status = datetime_time_init_ascii(&datetimeIn.time, str);
|
||||
zassert_true(status, NULL);
|
||||
diff = datetime_compare(&datetimeOut, &datetimeIn);
|
||||
zassert_equal(diff, 0, NULL);
|
||||
/* test date stringify */
|
||||
str_len = datetime_date_to_ascii(&datetimeIn.date, str, sizeof(str));
|
||||
zassert_true(str_len > 0, NULL);
|
||||
status = datetime_date_init_ascii(&datetimeIn.date, str);
|
||||
zassert_true(status, NULL);
|
||||
diff = datetime_compare(&datetimeOut, &datetimeIn);
|
||||
zassert_equal(diff, 0, NULL);
|
||||
/* test for invalid date tag */
|
||||
apdu_len = bacapp_encode_datetime(apdu, &datetimeIn);
|
||||
encode_tag(apdu, BACNET_APPLICATION_TAG_REAL, false, 4);
|
||||
|
||||
@@ -54,6 +54,8 @@ static void testTimestampTime(void)
|
||||
BACNET_TIMESTAMP testTimestampIn;
|
||||
BACNET_TIMESTAMP testTimestampOut;
|
||||
uint8_t buffer[MAX_APDU];
|
||||
bool status = false;
|
||||
char str[64] = "";
|
||||
int len;
|
||||
int test_len;
|
||||
|
||||
@@ -78,6 +80,12 @@ static void testTimestampTime(void)
|
||||
testTimestampIn.value.time.sec, testTimestampOut.value.time.sec, NULL);
|
||||
zassert_equal(testTimestampIn.value.time.hundredths,
|
||||
testTimestampOut.value.time.hundredths, NULL);
|
||||
|
||||
bacapp_timestamp_to_ascii(str, sizeof(str), &testTimestampIn);
|
||||
status = bacapp_timestamp_init_ascii(&testTimestampOut, str);
|
||||
zassert_true(status, NULL);
|
||||
status = bacapp_timestamp_same(&testTimestampIn, &testTimestampOut);
|
||||
zassert_true(status, NULL);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
|
||||
Reference in New Issue
Block a user