use_long_long_0.cpp 661 B

123456789101112131415161718192021222324252627282930
  1. #define ARDUINOJSON_USE_LONG_LONG 0
  2. #include <ArduinoJson.h>
  3. #include <catch.hpp>
  4. template <size_t size_of_long>
  5. std::string get_expected_json();
  6. template <>
  7. std::string get_expected_json<4>() {
  8. return "{\"A\":2899336981,\"B\":2129924785}";
  9. }
  10. template <>
  11. std::string get_expected_json<8>() {
  12. return "{\"A\":123456789123456789,\"B\":987654321987654321}";
  13. }
  14. TEST_CASE("ARDUINOJSON_USE_LONG_LONG == 0") {
  15. DynamicJsonDocument doc(4096);
  16. JsonObject root = doc.to<JsonObject>();
  17. root["A"] = 123456789123456789;
  18. root["B"] = 987654321987654321;
  19. std::string json;
  20. serializeJson(doc, json);
  21. REQUIRE(json == get_expected_json<sizeof(long)>());
  22. }