// ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2018 // MIT License #include #include #include #include template void checkValue(T expected) { JsonVariant variant = expected; REQUIRE(expected == variant.as()); } template void checkReference(T &expected) { JsonVariant variant = expected; REQUIRE(expected == variant.as()); } template void checkNumericType() { T min = std::numeric_limits::min(); T max = std::numeric_limits::max(); JsonVariant variantMin(min); JsonVariant variantMax(max); REQUIRE(min == variantMin.as()); REQUIRE(max == variantMax.as()); } TEST_CASE("JsonVariant set()/get()") { #if ARDUINOJSON_USE_LONG_LONG || ARDUINOJSON_USE_INT64 SECTION("SizeOfJsonInteger") { REQUIRE(8 == sizeof(Internals::JsonInteger)); } #endif SECTION("Null") { checkValue(NULL); } SECTION("String") { checkValue("hello"); } SECTION("False") { checkValue(false); } SECTION("True") { checkValue(true); } SECTION("Double") { checkNumericType(); } SECTION("Float") { checkNumericType(); } SECTION("Char") { checkNumericType(); } SECTION("SChar") { checkNumericType(); } SECTION("SInt") { checkNumericType(); } SECTION("SLong") { checkNumericType(); } SECTION("SShort") { checkNumericType(); } SECTION("UChar") { checkNumericType(); } SECTION("UInt") { checkNumericType(); } SECTION("ULong") { checkNumericType(); } SECTION("UShort") { checkNumericType(); } #if ARDUINOJSON_USE_LONG_LONG || ARDUINOJSON_USE_INT64 SECTION("LongLong") { checkNumericType(); } SECTION("ULongLong") { checkNumericType(); } #endif SECTION("Int8") { checkNumericType(); } SECTION("Uint8") { checkNumericType(); } SECTION("Int16") { checkNumericType(); } SECTION("Uint16") { checkNumericType(); } SECTION("Int32") { checkNumericType(); } SECTION("Uint32") { checkNumericType(); } #if ARDUINOJSON_USE_LONG_LONG || ARDUINOJSON_USE_INT64 SECTION("Int64") { checkNumericType(); } SECTION("Uint64") { checkNumericType(); } #endif SECTION("CanStoreObject") { DynamicJsonObject object; checkReference(object); } }