diff --git a/src/Datapoint/ConversionHelpers.cpp b/src/Datapoint/ConversionHelpers.cpp index 930a2c9..583f6df 100644 --- a/src/Datapoint/ConversionHelpers.cpp +++ b/src/Datapoint/ConversionHelpers.cpp @@ -94,7 +94,7 @@ std::size_t decodeSchedule(const uint8_t* data, std::size_t len, char* output, s hour = 0; minutes = 0; } - int result = snprintf(&output[pos], maxLen - result, "%u.02:%u.02", hour, minutes); + int result = snprintf(&output[pos], maxLen - pos, "%u.02:%u.02", hour, minutes); if (result < 0) return 0; pos += result; if (i < 7) { diff --git a/test/test_Datapoint/test_Datapoint.cpp b/test/test_Datapoint/test_Datapoint.cpp index dbbde68..a3d7fbb 100644 --- a/test/test_Datapoint/test_Datapoint.cpp +++ b/test/test_Datapoint/test_Datapoint.cpp @@ -204,7 +204,7 @@ void test_COPEncode() { TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, buffer, len); } -void test_Schedule() { +void test_ScheduleEncode() { const char* schedule = "7:30 08:30 16:20 23:10"; const uint8_t expected[] = {0x3B, 0x43, 0x82, 0xB9, 0x00, 0x00, 0x00, 0x00}; const size_t numSchedules = 2; @@ -235,6 +235,6 @@ int main() { RUN_TEST(test_CountShortEncode); RUN_TEST(test_COPDecode); RUN_TEST(test_COPEncode); - RUN_TEST(test_Schedule); + RUN_TEST(test_ScheduleEncode); return UNITY_END(); } \ No newline at end of file