Issue34.cpp 978 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright Benoit Blanchon 2014-2015
  2. // MIT License
  3. //
  4. // Arduino JSON library
  5. // https://github.com/bblanchon/ArduinoJson
  6. #include <gtest/gtest.h>
  7. #include <ArduinoJson.h>
  8. class Issue34 : public testing::Test {
  9. protected:
  10. template <typename T>
  11. void test_with_value(T expected) {
  12. StaticJsonBuffer<JSON_OBJECT_SIZE(1)> jsonBuffer;
  13. JsonObject& jsonObject = jsonBuffer.createObject();
  14. jsonObject["key"] = expected;
  15. T actual = jsonObject["key"];
  16. ASSERT_EQ(expected, actual);
  17. }
  18. };
  19. TEST_F(Issue34, int8_t) { test_with_value<int8_t>(1); }
  20. TEST_F(Issue34, uint8_t) { test_with_value<uint8_t>(2); }
  21. TEST_F(Issue34, int16_t) { test_with_value<int16_t>(3); }
  22. TEST_F(Issue34, uint16_t) { test_with_value<uint16_t>(4); }
  23. TEST_F(Issue34, int32_t) { test_with_value<int32_t>(5); }
  24. TEST_F(Issue34, uint32_t) { test_with_value<uint32_t>(6); }
  25. TEST_F(Issue34, float) { test_with_value<float>(7); }
  26. TEST_F(Issue34, double) { test_with_value<double>(8); }