Test empty nested arrays

This commit is contained in:
Benoit Blanchon
2014-08-25 11:01:22 +02:00
parent dbc3bee3a0
commit 981adf1989
2 changed files with 24 additions and 2 deletions

View File

@ -11,9 +11,21 @@ size_t IndentedPrintDecorator::write(uint8_t c)
{ {
case '{': case '{':
case '[': case '[':
indent++;
size_t n;
if (previousChar == '{' || previousChar == '[')
{
n = writeln() + sink.write(c);
}
else
{
n = sink.write(c);
}
previousChar = c; previousChar = c;
return sink.write(c); indent++;
return n;
case '}': case '}':
case ']': case ']':

View File

@ -44,6 +44,16 @@ namespace JsonGeneratorTests
"]"); "]");
} }
TEST_METHOD(EmptyNestedArrays)
{
whenInputIs("[[],[]]");
outputMustBe(
"[\n"
" [],\n"
" []\n"
"]");
}
private: private:
void whenInputIs(const char input[]) void whenInputIs(const char input[])