mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-22 23:07:29 +02:00
Moved ancillary files to extras/
(fixes #1011)
This commit is contained in:
25
extras/tests/MixedConfiguration/enable_nan_0.cpp
Normal file
25
extras/tests/MixedConfiguration/enable_nan_0.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#define ARDUINOJSON_ENABLE_NAN 0
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
#include <catch.hpp>
|
||||
#include <limits>
|
||||
|
||||
TEST_CASE("ARDUINOJSON_ENABLE_NAN == 0") {
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonObject root = doc.to<JsonObject>();
|
||||
|
||||
SECTION("serializeJson()") {
|
||||
root["X"] = std::numeric_limits<double>::signaling_NaN();
|
||||
|
||||
std::string json;
|
||||
serializeJson(doc, json);
|
||||
|
||||
REQUIRE(json == "{\"X\":null}");
|
||||
}
|
||||
|
||||
SECTION("deserializeJson()") {
|
||||
auto err = deserializeJson(doc, "{\"X\":NaN}");
|
||||
|
||||
REQUIRE(err == DeserializationError::InvalidInput);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user