mirror of
https://github.com/DaveGamble/cJSON.git
synced 2024-12-27 14:14:07 +08:00
tests: test trim_trailing_zeroes
This commit is contained in:
parent
dd4cb5400f
commit
0c0dd4a5b0
@ -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();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user