Add even more tests
This commit is contained in:
parent
905251e586
commit
af8fde1222
4 changed files with 338 additions and 0 deletions
|
|
@ -31,6 +31,8 @@ void tearDown()
|
|||
void test_json_array_empty()
|
||||
{
|
||||
json_begin_array(&json);
|
||||
{
|
||||
}
|
||||
json_end_array(&json);
|
||||
fflush(tmp);
|
||||
rewind(tmp);
|
||||
|
|
@ -141,6 +143,25 @@ void test_json_array_mixed()
|
|||
TEST_ASSERT_EQUAL_STRING("[\"string\",42,3.14,true,null]", buffer);
|
||||
}
|
||||
|
||||
void test_json_array_nested()
|
||||
{
|
||||
json_begin_array(&json);
|
||||
{
|
||||
json_begin_array(&json);
|
||||
{
|
||||
}
|
||||
json_end_array(&json);
|
||||
}
|
||||
json_end_array(&json);
|
||||
fflush(tmp);
|
||||
rewind(tmp);
|
||||
|
||||
auto n = fread(buffer, 1, sizeof(buffer) - 1, tmp);
|
||||
buffer[n] = '\0';
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("[[]]", buffer);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
UNITY_BEGIN();
|
||||
|
|
@ -152,6 +173,7 @@ int main()
|
|||
RUN_TEST(test_json_array_bool);
|
||||
RUN_TEST(test_json_array_null);
|
||||
RUN_TEST(test_json_array_mixed);
|
||||
RUN_TEST(test_json_array_nested);
|
||||
}
|
||||
return UNITY_END();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue