Test initial size() of DynamicJsonBuffer

This commit is contained in:
Benoit Blanchon
2014-12-11 21:05:45 +01:00
parent e2d591b9ff
commit 5a74beb7e2
2 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,25 @@
// Copyright Benoit Blanchon 2014
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
#pragma once
#include "JsonBuffer.hpp"
namespace ArduinoJson {
// Implements a JsonBuffer with dynamic memory allocation.
// You are strongly encouraged to consider using StaticJsonBuffer which is much
// more suitable for embedded systems.
class DynamicJsonBuffer : public JsonBuffer {
public:
explicit DynamicJsonBuffer() {}
size_t size() const { return 0; }
protected:
virtual void* alloc(size_t bytes) { return NULL; }
};
}

View File

@ -0,0 +1,21 @@
// Copyright Benoit Blanchon 2014
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
#include <gtest/gtest.h>
#define protected public
#include <ArduinoJson/DynamicJsonBuffer.hpp>
using namespace ArduinoJson;
class DynamicJsonBuffer_Basic_Tests : public testing::Test {
protected:
DynamicJsonBuffer buffer;
};
TEST_F(DynamicJsonBuffer_Basic_Tests, InitialSizeIsZero) {
ASSERT_EQ(0, buffer.size());
}