forked from bblanchon/ArduinoJson
Test that size can't go above capacity
This commit is contained in:
@ -14,7 +14,12 @@ public:
|
|||||||
|
|
||||||
virtual ~StaticJsonBuffer() {}
|
virtual ~StaticJsonBuffer() {}
|
||||||
|
|
||||||
/*JsonObject*/void createObject() { _size++; }
|
/*JsonObject*/
|
||||||
|
void createObject()
|
||||||
|
{
|
||||||
|
if (_size < CAPACITY)
|
||||||
|
_size++;
|
||||||
|
}
|
||||||
|
|
||||||
int capacity()
|
int capacity()
|
||||||
{
|
{
|
||||||
|
@ -23,3 +23,14 @@ TEST(StaticJsonBuffer, WhenCreateObjectIsCalled_ThenSizeIsIncreasedByOne)
|
|||||||
json.createObject();
|
json.createObject();
|
||||||
EXPECT_EQ(2, json.size());
|
EXPECT_EQ(2, json.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(StaticJsonBuffer, GivenBufferIsFull_WhenCreateObjectIsCalled_ThenSizeDoesNotChange)
|
||||||
|
{
|
||||||
|
StaticJsonBuffer<1> json;
|
||||||
|
|
||||||
|
json.createObject();
|
||||||
|
EXPECT_EQ(1, json.size());
|
||||||
|
|
||||||
|
json.createObject();
|
||||||
|
EXPECT_EQ(1, json.size());
|
||||||
|
}
|
Reference in New Issue
Block a user