// Copyright Benoit Blanchon 2014-2016 // MIT License // // Arduino JSON library // https://github.com/bblanchon/ArduinoJson // If you like this project, please add a star! #include #include class JsonVariant_Storage_Tests : public ::testing::Test { protected: template void testValue(T expected) { _actual = expected; EXPECT_EQ(expected, _actual.as()); } template void testReference(T &expected) { _actual = expected; EXPECT_EQ(expected, _actual.as()); } private: JsonVariant _actual; }; TEST_F(JsonVariant_Storage_Tests, Double) { testValue(123.45); } TEST_F(JsonVariant_Storage_Tests, False) { testValue(false); } TEST_F(JsonVariant_Storage_Tests, Float) { testValue(123.45f); } TEST_F(JsonVariant_Storage_Tests, Null) { testValue(NULL); } TEST_F(JsonVariant_Storage_Tests, SChar) { testValue(123); } TEST_F(JsonVariant_Storage_Tests, SInt) { testValue(123); } TEST_F(JsonVariant_Storage_Tests, SLong) { testValue(123L); } TEST_F(JsonVariant_Storage_Tests, SShort) { testValue(123); } TEST_F(JsonVariant_Storage_Tests, String) { testValue("hello"); } TEST_F(JsonVariant_Storage_Tests, True) { testValue(true); } TEST_F(JsonVariant_Storage_Tests, UChar) { testValue(123); } TEST_F(JsonVariant_Storage_Tests, UInt) { testValue(123U); } TEST_F(JsonVariant_Storage_Tests, ULong) { testValue(123UL); } TEST_F(JsonVariant_Storage_Tests, UShort) { testValue(123); } TEST_F(JsonVariant_Storage_Tests, CanStoreObject) { DynamicJsonBuffer jsonBuffer; JsonObject &object = jsonBuffer.createObject(); testReference(object); }