mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-06-25 01:11:35 +02:00
Undef true
and false
macros
Replacing `true` with `1` changes `JsonString("ABC", true)` into `JsonString("ABC", 1)`, so all static strings had a length of 1. This is a workaround for arduino/ArduinoCore-sam#50 Fixes #2181
This commit is contained in:
@ -1,6 +1,11 @@
|
|||||||
ArduinoJson: change log
|
ArduinoJson: change log
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
|
HEAD
|
||||||
|
----
|
||||||
|
|
||||||
|
* Fix truncated strings on Arduino Due (issue #2181)
|
||||||
|
|
||||||
v7.4.1 (2025-04-11)
|
v7.4.1 (2025-04-11)
|
||||||
------
|
------
|
||||||
|
|
||||||
|
@ -29,3 +29,23 @@ set_tests_properties(Misc
|
|||||||
PROPERTIES
|
PROPERTIES
|
||||||
LABELS "Catch"
|
LABELS "Catch"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_executable(Issue2181
|
||||||
|
issue2181.cpp # Cannot be linked with other tests
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(Issue2181 PROPERTIES UNITY_BUILD OFF)
|
||||||
|
|
||||||
|
add_test(Issue2181 Issue2181)
|
||||||
|
|
||||||
|
set_tests_properties(Issue2181
|
||||||
|
PROPERTIES
|
||||||
|
LABELS "Catch"
|
||||||
|
)
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
target_compile_options(Issue2181
|
||||||
|
PRIVATE
|
||||||
|
-Wno-keyword-macro # keyword is hidden by macro definition
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
15
extras/tests/Misc/issue2181.cpp
Normal file
15
extras/tests/Misc/issue2181.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// ArduinoJson - https://arduinojson.org
|
||||||
|
// Copyright © 2014-2025, Benoit BLANCHON
|
||||||
|
// MIT License
|
||||||
|
|
||||||
|
#define true 0x1
|
||||||
|
#define false 0x0
|
||||||
|
|
||||||
|
#include <ArduinoJson.h>
|
||||||
|
#include <catch.hpp>
|
||||||
|
|
||||||
|
TEST_CASE("Issue #2181") {
|
||||||
|
JsonDocument doc;
|
||||||
|
doc["hello"] = "world";
|
||||||
|
REQUIRE(doc.as<std::string>() == "{\"hello\":\"world\"}");
|
||||||
|
}
|
@ -26,6 +26,15 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Remove true and false macros defined by some cores, such as Arduino Due's
|
||||||
|
// See issues #2181 and arduino/ArduinoCore-sam#50
|
||||||
|
#ifdef true
|
||||||
|
# undef true
|
||||||
|
#endif
|
||||||
|
#ifdef false
|
||||||
|
# undef false
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "ArduinoJson/Array/JsonArray.hpp"
|
#include "ArduinoJson/Array/JsonArray.hpp"
|
||||||
#include "ArduinoJson/Object/JsonObject.hpp"
|
#include "ArduinoJson/Object/JsonObject.hpp"
|
||||||
#include "ArduinoJson/Variant/JsonVariantConst.hpp"
|
#include "ArduinoJson/Variant/JsonVariantConst.hpp"
|
||||||
|
Reference in New Issue
Block a user