// Copyright Benoit Blanchon 2014 // MIT License // // Arduino JSON library // https://github.com/bblanchon/ArduinoJson #include #include #include #include using namespace ArduinoJson; class JsonVariant_Storage_Tests : public ::testing::Test { protected: template void testValue(T expected) { actual.set(expected); EXPECT_EQ(expected, actual.as()); } template void testReference(T &expected) { actual.set(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) { StaticJsonBuffer<200> json; JsonObject &object = json.createObject(); testReference(object); }