Break build if using 64-bit integers with ARDUINOJSON_USE_LONG_LONG==0

This commit is contained in:
Benoit Blanchon
2020-05-12 18:53:26 +02:00
parent bc4c2dde33
commit f7de027617
10 changed files with 75 additions and 44 deletions

View File

@ -3,28 +3,14 @@
#include <catch.hpp>
template <size_t size_of_long>
std::string get_expected_json();
template <>
std::string get_expected_json<4>() {
return "{\"A\":2899336981,\"B\":2129924785}";
}
template <>
std::string get_expected_json<8>() {
return "{\"A\":123456789123456789,\"B\":987654321987654321}";
}
TEST_CASE("ARDUINOJSON_USE_LONG_LONG == 0") {
DynamicJsonDocument doc(4096);
JsonObject root = doc.to<JsonObject>();
root["A"] = 123456789123456789;
root["B"] = 987654321987654321;
doc["A"] = 42;
doc["B"] = 84;
std::string json;
serializeJson(doc, json);
REQUIRE(json == get_expected_json<sizeof(long)>());
REQUIRE(json == "{\"A\":42,\"B\":84}");
}