8000 Converted all StaticJsonBuffer::parseArray() tests · sarfata/ArduinoJson@b66867d · GitHub
[go: up one dir, main page]

Skip to content

Commit b66867d

Browse files
committed
Converted all StaticJsonBuffer::parseArray() tests
1 parent 5fbe0cf commit b66867d

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/ArduinoJson/StaticJsonArray.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class StaticJsonArray : public JsonArray {
2222
_buffer.alloc(sizeof(JsonArray));
2323
}
2424

25-
StaticJsonBufferBase* buffer() {
26-
return &_buffer;
25+
StaticJsonBufferBase& buffer() {
26+
return _buffer;
2727
}
2828
};
2929
}

src/ArduinoJson/parseJson.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ template <typename TDestination, typename TString>
1414
typename TypeTraits::EnableIf<!TypeTraits::IsArray<TString>::value, bool>::type
1515
parseJson(TDestination &destination, const TString &json,
1616
uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT) {
17-
return Internals::makeParser(destination.buffer(), json, nestingLimit)
17+
return Internals::makeParser(&destination.buffer(), json, nestingLimit)
1818
.parseArray(destination);
1919
}
2020
//
@@ -23,7 +23,7 @@ parseJson(TDestination &destination, const TString &json,
2323
template <typename TDestination, typename TString>
2424
bool parseJson(TDestination &destination, TString *json,
2525
uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT) {
26-
return Internals::makeParser(destination.buffer(), json, nestingLimit)
26+
return Internals::makeParser(&destination.buffer(), json, nestingLimit)
2727
.parseArray(destination);
2828
}
2929
//
@@ -32,7 +32,7 @@ bool parseJson(TDestination &destination, TString *json,
3232
template <typename TDestination, typename TString>
3333
bool parseJson(TDestination &destination, TString &json,
3434
uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT) {
35-
return Internals::makeParser(destination.buffer(), json, nestingLimit)
35+
return Internals::makeParser(&destination.buffer(), json, nestingLimit)
3636
.parseArray(destination);
3737
}
3838
}

test/StaticJsonBuffer/parseArray.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <ArduinoJson.h>
99
#include <catch.hpp>
1010

11+
// TODO: move
1112
TEST_CASE("StaticJsonBuffer::parseArray()") {
1213
SECTION("StaticJsonArray of the right size of 0 elements") {
1314
StaticJsonArray<JSON_ARRAY_SIZE(0)> arr;
@@ -49,10 +50,10 @@ TEST_CASE("StaticJsonBuffer::parseArray()") {
4950
REQUIRE(false == parseJson(arr, static_cast<const char*>(0)));
5051
}
5152

52-
SECTION("CopyStringNotSpaces") {
53-
StaticJsonBuffer<100> jsonBuffer;
54-
jsonBuffer.parseArray(" [ \"1234567\" ] ");
55-
REQUIRE(JSON_ARRAY_SIZE(1) + sizeof("1234567") == jsonBuffer.size());
53+
SECTION("Copy string not spaces") {
54+
StaticJsonArray<100> arr;
55+
parseJson(arr, " [ \"1234567\" ] ");
56+
REQUIRE(JSON_ARRAY_SIZE(1) + sizeof("1234567") == arr.buffer().size());
5657
// note we use a string of 8 bytes to be sure that the StaticJsonBuffer
5758
// will not insert bytes to enforce alignement
5859
}

0 commit comments

Comments
 (0)
0