mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2026-04-29 02:24:09 +02:00
Read MsgPack's 64-bit ints even if ARDUINOJSON_USE_LONG_LONG is 0
This commit is contained in:
@@ -3,14 +3,40 @@
|
||||
|
||||
#include <catch.hpp>
|
||||
|
||||
#include "Literals.hpp"
|
||||
|
||||
TEST_CASE("ARDUINOJSON_USE_LONG_LONG == 0") {
|
||||
JsonDocument doc;
|
||||
|
||||
doc["A"] = 42;
|
||||
doc["B"] = 84;
|
||||
SECTION("smoke test") {
|
||||
doc["A"] = 42;
|
||||
doc["B"] = 84;
|
||||
|
||||
std::string json;
|
||||
serializeJson(doc, json);
|
||||
std::string json;
|
||||
serializeJson(doc, json);
|
||||
|
||||
REQUIRE(json == "{\"A\":42,\"B\":84}");
|
||||
REQUIRE(json == "{\"A\":42,\"B\":84}");
|
||||
}
|
||||
|
||||
SECTION("deserializeMsgPack()") {
|
||||
SECTION("cf 00 00 00 00 ff ff ff ff") {
|
||||
auto err =
|
||||
deserializeMsgPack(doc, "\xcf\x00\x00\x00\x00\xff\xff\xff\xff"_s);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
REQUIRE(doc.as<uint32_t>() == 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
SECTION("cf 00 00 00 01 00 00 00 00") {
|
||||
auto err =
|
||||
deserializeMsgPack(doc, "\xcf\x00\x00\x00\x01\x00\x00\x00\x00"_s);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
#if defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ >= 8
|
||||
REQUIRE(doc.as<JsonInteger>() == 0x100000000);
|
||||
#else
|
||||
REQUIRE(doc.isNull());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user