mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-18 13:02:25 +02:00
Test an array with one element
This commit is contained in:
@ -10,14 +10,16 @@ size_t IndentedPrintDecorator::write(uint8_t c)
|
||||
switch (c)
|
||||
{
|
||||
case '{':
|
||||
case '[':
|
||||
indent++;
|
||||
previousChar = c;
|
||||
return sink.write(c);
|
||||
|
||||
case '}':
|
||||
case ']':
|
||||
indent--;
|
||||
|
||||
if (previousChar == '{')
|
||||
if (previousChar == '{' || previousChar == '[')
|
||||
{
|
||||
previousChar = c;
|
||||
return sink.write(c);
|
||||
@ -58,7 +60,7 @@ size_t IndentedPrintDecorator::write(uint8_t c)
|
||||
|
||||
default:
|
||||
|
||||
if (previousChar == '{')
|
||||
if (previousChar == '{' || previousChar == '[')
|
||||
{
|
||||
previousChar = c;
|
||||
return writeln() + sink.write(c);
|
||||
|
@ -12,7 +12,7 @@ using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
namespace JsonGeneratorTests
|
||||
{
|
||||
TEST_CLASS(IntentedPrintTests)
|
||||
TEST_CLASS(Indented_Array_Tests)
|
||||
{
|
||||
char buffer[1024];
|
||||
size_t returnValue;
|
||||
@ -25,6 +25,15 @@ namespace JsonGeneratorTests
|
||||
outputMustBe("[]");
|
||||
}
|
||||
|
||||
TEST_METHOD(OneElement)
|
||||
{
|
||||
whenInputIs("[1]");
|
||||
outputMustBe(
|
||||
"[\n"
|
||||
" 1\n"
|
||||
"]");
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void whenInputIs(const char input[])
|
||||
|
@ -12,7 +12,7 @@ using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
namespace JsonGeneratorTests
|
||||
{
|
||||
TEST_CLASS(IntentedPrintTests)
|
||||
TEST_CLASS(Indented_Object_Tests)
|
||||
{
|
||||
char buffer[1024];
|
||||
size_t returnValue;
|
||||
|
@ -12,7 +12,7 @@ using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
|
||||
namespace JsonGeneratorTests
|
||||
{
|
||||
TEST_CLASS(IntentedPrintTests)
|
||||
TEST_CLASS(Intented_String_Tests)
|
||||
{
|
||||
char buffer[1024];
|
||||
size_t returnValue;
|
||||
|
Reference in New Issue
Block a user