Add timestamp snprintf. Fix bacapp snprintf to account for string size zero behavior of snprintf.

This commit is contained in:
Steve Karg
2024-04-23 10:04:46 -05:00
parent 8729c00dbd
commit e73520a974
7 changed files with 299 additions and 142 deletions
+16
View File
@@ -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);