From 9ca32e664e6bb5d34b21cc17eb7adb095ab88dab Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Mon, 8 Dec 2014 20:22:01 +0100 Subject: [PATCH] Added unit tests for issue #34 --- test/Issue34.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/Issue34.cpp 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); }