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 | class Issue34 : public testing::Test {
|
---|
12 | protected:
|
---|
13 | template <typename T>
|
---|
14 | void test_with_value(T expected) {
|
---|
15 | StaticJsonBuffer<JSON_OBJECT_SIZE(1)> jsonBuffer;
|
---|
16 |
|
---|
17 | JsonObject& jsonObject = jsonBuffer.createObject();
|
---|
18 |
|
---|
19 | jsonObject["key"] = expected;
|
---|
20 | T actual = jsonObject["key"];
|
---|
21 |
|
---|
22 | ASSERT_EQ(expected, actual);
|
---|
23 | }
|
---|
24 | };
|
---|
25 |
|
---|
26 | TEST_F(Issue34, int8_t) { test_with_value<int8_t>(1); }
|
---|
27 |
|
---|
28 | TEST_F(Issue34, uint8_t) { test_with_value<uint8_t>(2); }
|
---|
29 |
|
---|
30 | TEST_F(Issue34, int16_t) { test_with_value<int16_t>(3); }
|
---|
31 |
|
---|
32 | TEST_F(Issue34, uint16_t) { test_with_value<uint16_t>(4); }
|
---|
33 |
|
---|
34 | TEST_F(Issue34, int32_t) { test_with_value<int32_t>(5); }
|
---|
35 |
|
---|
36 | TEST_F(Issue34, uint32_t) { test_with_value<uint32_t>(6); }
|
---|
37 |
|
---|
38 | TEST_F(Issue34, float) { test_with_value<float>(7); }
|
---|
39 |
|
---|
40 | TEST_F(Issue34, double) { test_with_value<double>(8); }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.