Issue34.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #include <gtest/gtest.h>
  8. #include <ArduinoJson.h>
  9. class Issue34 : public testing::Test {
  10. protected:
  11. template <typename T>
  12. void test_with_value(T expected) {
  13. StaticJsonBuffer<JSON_OBJECT_SIZE(1)> jsonBuffer;
  14. JsonObject& jsonObject = jsonBuffer.createObject();
  15. jsonObject["key"] = expected;
  16. T actual = jsonObject["key"];
  17. ASSERT_EQ(expected, actual);
  18. }
  19. };
  20. TEST_F(Issue34, int8_t) { test_with_value<int8_t>(1); }
  21. TEST_F(Issue34, uint8_t) { test_with_value<uint8_t>(2); }
  22. TEST_F(Issue34, int16_t) { test_with_value<int16_t>(3); }
  23. TEST_F(Issue34, uint16_t) { test_with_value<uint16_t>(4); }
  24. TEST_F(Issue34, int32_t) { test_with_value<int32_t>(5); }
  25. TEST_F(Issue34, uint32_t) { test_with_value<uint32_t>(6); }
  26. TEST_F(Issue34, float) { test_with_value<float>(7); }
  27. TEST_F(Issue34, double) { test_with_value<double>(8); }