mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-17 12:32:17 +02:00
44 lines
985 B
C++
44 lines
985 B
C++
![]() |
/*
|
||
|
* Arduino JSON library
|
||
|
* Benoit Blanchon 2014 - MIT License
|
||
|
*/
|
||
|
|
||
|
#include "CppUnitTest.h"
|
||
|
#include "IndentedPrintDecorator.h"
|
||
|
#include "StringBuilder.h"
|
||
|
|
||
|
using namespace ArduinoJson::Internals;
|
||
|
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||
|
|
||
|
namespace JsonGeneratorTests
|
||
|
{
|
||
|
TEST_CLASS(IntentedPrintTests)
|
||
|
{
|
||
|
char buffer[1024];
|
||
|
size_t returnValue;
|
||
|
|
||
|
public:
|
||
|
|
||
|
TEST_METHOD(EmptyArray)
|
||
|
{
|
||
|
whenInputIs("[]");
|
||
|
outputMustBe("[]");
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
|
||
|
void whenInputIs(const char input[])
|
||
|
{
|
||
|
StringBuilder sb(buffer, sizeof(buffer));
|
||
|
IndentedPrintDecorator decorator(sb);
|
||
|
|
||
|
returnValue = decorator.print(input);
|
||
|
}
|
||
|
|
||
|
void outputMustBe(const char* expected)
|
||
|
{
|
||
|
Assert::AreEqual(expected, buffer);
|
||
|
Assert::AreEqual(strlen(expected), returnValue);
|
||
|
}
|
||
|
};
|
||
|
}
|