#define ARDUINOJSON_ENABLE_NAN 1 #include #include #include namespace my { using ArduinoJson::detail::isnan; } // namespace my TEST_CASE("ARDUINOJSON_ENABLE_NAN == 1") { JsonDocument doc; JsonObject root = doc.to(); SECTION("serializeJson()") { root["X"] = std::numeric_limits::signaling_NaN(); std::string json; serializeJson(doc, json); REQUIRE(json == "{\"X\":NaN}"); } SECTION("deserializeJson()") { DeserializationError err = deserializeJson(doc, "{\"X\":NaN}"); float x = doc["X"]; REQUIRE(err == DeserializationError::Ok); REQUIRE(my::isnan(x)); } }