diff --git a/test/Issue34.cpp b/test/Issue34.cpp new file mode 100644 index 00000000..68a7ebfb --- /dev/null +++ b/test/Issue34.cpp @@ -0,0 +1,39 @@ +// Copyright Benoit Blanchon 2014 +// MIT License +// +// Arduino JSON library +// https://github.com/bblanchon/ArduinoJson + +#include +#include + +class Issue34 : public testing::Test { + protected: + template + void test_with_value(T expected) { + StaticJsonBuffer<200> jsonBuffer; + + JsonObject& jsonObject = jsonBuffer.createObject(); + + jsonObject["key"] = expected; + T actual = jsonObject["key"]; + + ASSERT_EQ(expected, actual); + } +}; + +TEST_F(Issue34, int8_t) { test_with_value(1); } + +TEST_F(Issue34, uint8_t) { test_with_value(2); } + +TEST_F(Issue34, int16_t) { test_with_value(3); } + +TEST_F(Issue34, uint16_t) { test_with_value(4); } + +TEST_F(Issue34, int32_t) { test_with_value(5); } + +TEST_F(Issue34, uint32_t) { test_with_value(6); } + +TEST_F(Issue34, float) { test_with_value(7); } + +TEST_F(Issue34, double) { test_with_value(8); }