Line | |
---|
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 | #define TEST_(name) TEST(JsonObject_Basic_Tests, name)
|
---|
12 |
|
---|
13 | TEST_(ContainsKeyReturnsFalseForNonExistingKey) {
|
---|
14 | DynamicJsonBuffer _jsonBuffer;
|
---|
15 | JsonObject& _object = _jsonBuffer.createObject();
|
---|
16 |
|
---|
17 | _object.set("hello", 42);
|
---|
18 |
|
---|
19 | EXPECT_FALSE(_object.containsKey("world"));
|
---|
20 | }
|
---|
21 |
|
---|
22 | TEST_(ContainsKeyReturnsTrueForDefinedValue) {
|
---|
23 | DynamicJsonBuffer _jsonBuffer;
|
---|
24 | JsonObject& _object = _jsonBuffer.createObject();
|
---|
25 |
|
---|
26 | _object.set("hello", 42);
|
---|
27 |
|
---|
28 | EXPECT_TRUE(_object.containsKey("hello"));
|
---|
29 | }
|
---|
30 |
|
---|
31 | TEST_(ContainsKeyReturnsFalseAfterRemove) {
|
---|
32 | DynamicJsonBuffer _jsonBuffer;
|
---|
33 | JsonObject& _object = _jsonBuffer.createObject();
|
---|
34 |
|
---|
35 | _object.set("hello", 42);
|
---|
36 | _object.remove("hello");
|
---|
37 |
|
---|
38 | EXPECT_FALSE(_object.containsKey("hello"));
|
---|
39 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.