Reduced memory consumption by not duplicating spaces and comments

This commit is contained in:
Benoit Blanchon
2016-12-29 17:26:16 +01:00
parent 8032a4b564
commit 3f96e070ce
20 changed files with 596 additions and 287 deletions

View File

@ -5,12 +5,12 @@
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#include <gtest/gtest.h>
#include <ArduinoJson.h>
#include <gtest/gtest.h>
class StaticJsonBuffer_ParseArray_Tests : public testing::Test {
protected:
void with(JsonBuffer& jsonBuffer) {
void with(StaticJsonBufferBase& jsonBuffer) {
_jsonBuffer = &jsonBuffer;
}
@ -27,7 +27,7 @@ class StaticJsonBuffer_ParseArray_Tests : public testing::Test {
}
private:
JsonBuffer* _jsonBuffer;
StaticJsonBufferBase* _jsonBuffer;
char _jsonString[256];
};
@ -86,3 +86,11 @@ TEST_F(StaticJsonBuffer_ParseArray_Tests, ConstCharPtrNull) {
.parseArray(static_cast<const char*>(0))
.success());
}
TEST_F(StaticJsonBuffer_ParseArray_Tests, CopyStringNotSpaces) {
StaticJsonBuffer<100> jsonBuffer;
jsonBuffer.parseArray(" [ \"1234567\" ] ");
ASSERT_EQ(JSON_ARRAY_SIZE(1) + sizeof("1234567"), jsonBuffer.size());
// note we use a string of 8 bytes to be sure that the StaticJsonBuffer
// will not insert bytes to enforce alignement
}