Rev | Line | |
---|
[209] | 1 | // Copyright Benoit Blanchon 2014-2016
|
---|
| 2 | // MIT License
|
---|
| 3 | //
|
---|
| 4 | // Arduino JSON library
|
---|
| 5 | // https://github.com/bblanchon/ArduinoJson
|
---|
| 6 | // If you like this project, please add a star!
|
---|
| 7 |
|
---|
| 8 | #include <gtest/gtest.h>
|
---|
| 9 | #include <ArduinoJson.h>
|
---|
| 10 |
|
---|
| 11 | class NoMemoryAllocator {
|
---|
| 12 | public:
|
---|
| 13 | void* allocate(size_t) { return NULL; }
|
---|
| 14 | void deallocate(void*) {}
|
---|
| 15 | };
|
---|
| 16 |
|
---|
| 17 | class DynamicJsonBuffer_NoMemory_Tests : public ::testing::Test {
|
---|
| 18 | protected:
|
---|
| 19 | Internals::BlockJsonBuffer<NoMemoryAllocator> _jsonBuffer;
|
---|
| 20 | };
|
---|
| 21 |
|
---|
| 22 | TEST_F(DynamicJsonBuffer_NoMemory_Tests, FixCodeCoverage) {
|
---|
| 23 | // call this function to fix code coverage
|
---|
| 24 | NoMemoryAllocator().deallocate(NULL);
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | TEST_F(DynamicJsonBuffer_NoMemory_Tests, CreateArray) {
|
---|
| 28 | ASSERT_FALSE(_jsonBuffer.createArray().success());
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | TEST_F(DynamicJsonBuffer_NoMemory_Tests, CreateObject) {
|
---|
| 32 | ASSERT_FALSE(_jsonBuffer.createObject().success());
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | TEST_F(DynamicJsonBuffer_NoMemory_Tests, ParseArray) {
|
---|
| 36 | char json[] = "[]";
|
---|
| 37 | ASSERT_FALSE(_jsonBuffer.parseArray(json).success());
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | TEST_F(DynamicJsonBuffer_NoMemory_Tests, ParseObject) {
|
---|
| 41 | char json[] = "{}";
|
---|
| 42 | ASSERT_FALSE(_jsonBuffer.parseObject(json).success());
|
---|
| 43 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.