tests: test trim_trailing_zeroes

This commit is contained in:
Max Bruckner 2017-03-01 18:29:01 +01:00
parent dd4cb5400f
commit 0c0dd4a5b0

View File

@ -87,6 +87,22 @@ static void print_number_should_print_non_number(void)
/* assert_print_number("null", -INFTY); */ /* assert_print_number("null", -INFTY); */
} }
static void trim_trailing_zeroes_should_trim_trailing_zeroes(void)
{
printbuffer buffer;
unsigned char number[100];
unsigned char *pointer = NULL;
buffer.length = sizeof(number);
buffer.buffer = number;
strcpy((char*)number, "10.00");
buffer.offset = sizeof("10.00") - 1;
pointer = trim_trailing_zeroes(&buffer);
TEST_ASSERT_EQUAL_UINT8('\0', *pointer);
TEST_ASSERT_EQUAL_STRING("10", number);
TEST_ASSERT_EQUAL_UINT(sizeof("10") - 1, buffer.offset);
}
int main(void) int main(void)
{ {
/* initialize cJSON item */ /* initialize cJSON item */
@ -98,6 +114,7 @@ int main(void)
RUN_TEST(print_number_should_print_positive_reals); RUN_TEST(print_number_should_print_positive_reals);
RUN_TEST(print_number_should_print_negative_reals); RUN_TEST(print_number_should_print_negative_reals);
RUN_TEST(print_number_should_print_non_number); RUN_TEST(print_number_should_print_non_number);
RUN_TEST(trim_trailing_zeroes_should_trim_trailing_zeroes);
return UNITY_END(); return UNITY_END();
} }