forked from bblanchon/ArduinoJson
Compare commits
52 Commits
Author | SHA1 | Date | |
---|---|---|---|
1b8107094f | |||
8721ac88b1 | |||
6da6f921cd | |||
ef63757b1a | |||
3a169df0a5 | |||
d4f819f1f0 | |||
16fe3c0acc | |||
fd8f4eb3a6 | |||
b261eca865 | |||
a37480eec9 | |||
713aaa3d68 | |||
7d1d0c4e67 | |||
4ad05dbaef | |||
38371aae62 | |||
498a2e4c1e | |||
2078871f36 | |||
140525b7a0 | |||
1a81d46a97 | |||
4c4c4688a9 | |||
b47ac27ac6 | |||
ed18e77655 | |||
fcbec6eb6d | |||
f5c25823bc | |||
f00dfd7bfe | |||
dcca4214f5 | |||
1e9cc285bb | |||
b9c4a0c5f6 | |||
0d339300f9 | |||
63d7d87080 | |||
2ee655f9ba | |||
61a4195ed4 | |||
a6f029ded0 | |||
b54de58e6b | |||
795e37278f | |||
7ce1039d7c | |||
aba42faf69 | |||
815326d42e | |||
7d40a541c9 | |||
2507ee2e56 | |||
a0a451195b | |||
ce247a5637 | |||
59f9c9747f | |||
fec088e3ed | |||
4980ee8fb9 | |||
2ed77d2cc3 | |||
630107ae8a | |||
4eb8074358 | |||
80a02cd90d | |||
7427888e05 | |||
90c1d549a8 | |||
2af003e4e2 | |||
eaf55e174b |
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
custom: https://arduinojson.org/book/
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -6,7 +6,7 @@
|
|||||||
/sftp-config.json
|
/sftp-config.json
|
||||||
.tags
|
.tags
|
||||||
.tags_sorted_by_file
|
.tags_sorted_by_file
|
||||||
/fuzzing/*_fuzzer
|
/extras/fuzzing/*_fuzzer
|
||||||
/fuzzing/*_fuzzer.options
|
/extras/fuzzing/*_fuzzer.options
|
||||||
/fuzzing/*_fuzzer_seed_corpus.zip
|
/extras/fuzzing/*_fuzzer_seed_corpus.zip
|
||||||
.vs/
|
.vs/
|
||||||
|
12
.travis.yml
12
.travis.yml
@ -84,12 +84,12 @@ matrix:
|
|||||||
env: SCRIPT=test _CC=clang-4.0 _CXX=clang++-4.0
|
env: SCRIPT=test _CC=clang-4.0 _CXX=clang++-4.0
|
||||||
- addons:
|
- addons:
|
||||||
apt:
|
apt:
|
||||||
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-5.0']
|
sources: ['ubuntu-toolchain-r-test']
|
||||||
packages: ['clang-5.0']
|
packages: ['clang-5.0']
|
||||||
env: SCRIPT=test _CC=clang-5.0 _CXX=clang++-5.0
|
env: SCRIPT=test _CC=clang-5.0 _CXX=clang++-5.0
|
||||||
- addons:
|
- addons:
|
||||||
apt:
|
apt:
|
||||||
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-6.0']
|
sources: ['ubuntu-toolchain-r-test']
|
||||||
packages: ['clang-6.0']
|
packages: ['clang-6.0']
|
||||||
env: SCRIPT=test _CC=clang-6.0 _CXX=clang++-6.0
|
env: SCRIPT=test _CC=clang-6.0 _CXX=clang++-6.0
|
||||||
- addons:
|
- addons:
|
||||||
@ -121,12 +121,12 @@ matrix:
|
|||||||
- env: SCRIPT=platformio BOARD=esp01
|
- env: SCRIPT=platformio BOARD=esp01
|
||||||
- addons:
|
- addons:
|
||||||
apt:
|
apt:
|
||||||
sources: ['ubuntu-toolchain-r-test','llvm-toolchain-trusty-6.0']
|
sources: ['ubuntu-toolchain-r-test']
|
||||||
packages: ['clang-6.0','llvm-6.0']
|
packages: ['clang-6.0','llvm-6.0']
|
||||||
env: SCRIPT=fuzz CLANG=6.0
|
env: SCRIPT=fuzz CLANG=6.0
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- "~/.platformio"
|
- "~/.platformio"
|
||||||
- "fuzzing/json_corpus"
|
- "extras/fuzzing/json_corpus"
|
||||||
- "fuzzing/msgpack_corpus"
|
- "extras/fuzzing/msgpack_corpus"
|
||||||
script: scripts/travis/$SCRIPT.sh
|
script: extras/ci/$SCRIPT.sh
|
||||||
|
102
CHANGELOG.md
102
CHANGELOG.md
@ -1,6 +1,108 @@
|
|||||||
ArduinoJson: change log
|
ArduinoJson: change log
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
|
v6.13.0 (2019-11-01)
|
||||||
|
-------
|
||||||
|
|
||||||
|
* Added support for custom writer/reader classes (issue #1088)
|
||||||
|
* Added conversion from `JsonArray` and `JsonObject` to `bool`, to be consistent with `JsonVariant`
|
||||||
|
* Fixed `deserializeJson()` when input contains duplicate keys (issue #1095)
|
||||||
|
* Improved `deserializeMsgPack()` speed by reading several bytes at once
|
||||||
|
* Added detection of Atmel AVR8/GNU C Compiler (issue #1112)
|
||||||
|
* Fixed deserializer that stopped reading at the first `0xFF` (PR #1118 by @mikee47)
|
||||||
|
* Fixed dangling reference in copies of `MemberProxy` and `ElementProxy` (issue #1120)
|
||||||
|
|
||||||
|
v6.12.0 (2019-09-05)
|
||||||
|
-------
|
||||||
|
|
||||||
|
* Use absolute instead of relative includes (issue #1072)
|
||||||
|
* Changed `JsonVariant::as<bool>()` to return `true` for any non-null value (issue #1005)
|
||||||
|
* Moved ancillary files to `extras/` (issue #1011)
|
||||||
|
|
||||||
|
v6.11.5 (2019-08-23)
|
||||||
|
-------
|
||||||
|
|
||||||
|
* Added fallback implementations of `strlen_P()`, `strncmp_P()`, `strcmp_P()`, and `memcpy_P()` (issue #1073)
|
||||||
|
|
||||||
|
v6.11.4 (2019-08-12)
|
||||||
|
-------
|
||||||
|
|
||||||
|
* Added `measureJson()` to the `ArduinoJson` namespace (PR #1069 by @nomis)
|
||||||
|
* Added support for `basic_string<char, traits, allocator>` (issue #1045)
|
||||||
|
* Fixed example `JsonConfigFile.ino` for ESP8266
|
||||||
|
* Include `Arduino.h` if `ARDUINO` is defined (PR #1071 by @nomis)
|
||||||
|
|
||||||
|
v6.11.3 (2019-07-22)
|
||||||
|
-------
|
||||||
|
|
||||||
|
* Added operators `==` and `!=` for `JsonDocument`, `ElementProxy`, and `MemberProxy`
|
||||||
|
* Fixed comparison of `JsonVariant` when one contains a linked string and the other contains an owned string (issue #1051)
|
||||||
|
|
||||||
|
v6.11.2 (2019-07-08)
|
||||||
|
-------
|
||||||
|
|
||||||
|
* Fixed assignment of `JsonDocument` to `JsonVariant` (issue #1023)
|
||||||
|
* Fix invalid conversion error on Particle Argon (issue #1035)
|
||||||
|
|
||||||
|
v6.11.1 (2019-06-21)
|
||||||
|
-------
|
||||||
|
|
||||||
|
* Fixed `serialized()` not working with Flash strings (issue #1030)
|
||||||
|
|
||||||
|
v6.11.0 (2019-05-26)
|
||||||
|
-------
|
||||||
|
|
||||||
|
* Fixed `deserializeJson()` silently accepting a `Stream*` (issue #978)
|
||||||
|
* Fixed invalid result from `operator|` (issue #981)
|
||||||
|
* Made `deserializeJson()` more picky about trailing characters (issue #980)
|
||||||
|
* Added `ARDUINOJSON_ENABLE_NAN` (default=0) to enable NaN in JSON (issue #973)
|
||||||
|
* Added `ARDUINOJSON_ENABLE_INFINITY` (default=0) to enable Infinity in JSON
|
||||||
|
* Removed implicit conversion in comparison operators (issue #998)
|
||||||
|
* Added lexicographical comparison for `JsonVariant`
|
||||||
|
* Added support for `nullptr` (issue #998)
|
||||||
|
|
||||||
|
> ### BREAKING CHANGES
|
||||||
|
>
|
||||||
|
> #### NaN and Infinity
|
||||||
|
>
|
||||||
|
> The JSON specification allows neither NaN not Infinity, but previous
|
||||||
|
> versions of ArduinoJson supported it. Now, ArduinoJson behaves like most
|
||||||
|
> other libraries: a NaN or and Infinity in the `JsonDocument`, becomes
|
||||||
|
> a `null` in the output JSON. Also, `deserializeJson()` returns
|
||||||
|
> `InvalidInput` if the JSON document contains NaN or Infinity.
|
||||||
|
>
|
||||||
|
> This version still supports NaN and Infinity in JSON documents, but
|
||||||
|
> it's disabled by default to be compatible with other JSON parsers.
|
||||||
|
> If you need the old behavior back, define `ARDUINOJSON_ENABLE_NAN` and
|
||||||
|
> `ARDUINOJSON_ENABLE_INFINITY` to `1`;:
|
||||||
|
>
|
||||||
|
> ```c++
|
||||||
|
> #define ARDUINOJSON_ENABLE_NAN 1
|
||||||
|
> #define ARDUINOJSON_ENABLE_INFINITY 1
|
||||||
|
> #include <ArduinoJson.h>
|
||||||
|
> ```
|
||||||
|
>
|
||||||
|
> #### The "or" operator
|
||||||
|
>
|
||||||
|
> This version slightly changes the behavior of the | operator when the
|
||||||
|
> variant contains a float and the user requests an integer.
|
||||||
|
>
|
||||||
|
> Older versions returned the floating point value truncated.
|
||||||
|
> Now, it returns the default value.
|
||||||
|
>
|
||||||
|
> ```c++
|
||||||
|
> // suppose variant contains 1.2
|
||||||
|
> int value = variant | 3;
|
||||||
|
>
|
||||||
|
> // old behavior:
|
||||||
|
> value == 1
|
||||||
|
>
|
||||||
|
> // new behavior
|
||||||
|
> value == 3
|
||||||
|
> ```
|
||||||
|
>
|
||||||
|
> If you need the old behavior, you must add `if (variant.is<float>())`.
|
||||||
|
|
||||||
v6.10.1 (2019-04-23)
|
v6.10.1 (2019-04-23)
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
@ -17,6 +17,5 @@ if(${COVERAGE})
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/src)
|
include_directories(${CMAKE_CURRENT_LIST_DIR}/src)
|
||||||
add_subdirectory(third-party/catch)
|
add_subdirectory(extras/tests)
|
||||||
add_subdirectory(test)
|
add_subdirectory(extras/fuzzing)
|
||||||
add_subdirectory(fuzzing)
|
|
||||||
|
@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
[](https://www.ardu-badge.com/ArduinoJson/6.10.1)
|
[](https://www.ardu-badge.com/ArduinoJson/6.13.0)
|
||||||
[](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x)
|
[](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x)
|
||||||
[](https://travis-ci.org/bblanchon/ArduinoJson)
|
[](https://travis-ci.org/bblanchon/ArduinoJson)
|
||||||
|
[](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson)
|
||||||
[](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x)
|
[](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x)
|
||||||
[](https://github.com/bblanchon/ArduinoJson)
|
[](https://github.com/bblanchon/ArduinoJson/stargazers)
|
||||||
|
|
||||||
ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
|
ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
version: 6.10.1.{build}
|
version: 6.13.0.{build}
|
||||||
environment:
|
environment:
|
||||||
matrix:
|
matrix:
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
@ -17,4 +17,4 @@ before_build:
|
|||||||
build_script:
|
build_script:
|
||||||
- cmake --build . --config %CONFIGURATION%
|
- cmake --build . --config %CONFIGURATION%
|
||||||
test_script:
|
test_script:
|
||||||
- ctest --output-on-failure .
|
- ctest -C %CONFIGURATION% --output-on-failure .
|
||||||
|
1
component.mk
Normal file
1
component.mk
Normal file
@ -0,0 +1 @@
|
|||||||
|
COMPONENT_ADD_INCLUDEDIRS := src
|
@ -11,6 +11,12 @@
|
|||||||
// "port": 2731
|
// "port": 2731
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
// To run this program, you need an SD card connected to the SPI bus as follows:
|
||||||
|
// * MOSI <-> pin 11
|
||||||
|
// * MISO <-> pin 12
|
||||||
|
// * CLK <-> pin 13
|
||||||
|
// * CS <-> pin 4
|
||||||
|
//
|
||||||
// https://arduinojson.org/v6/example/config/
|
// https://arduinojson.org/v6/example/config/
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
@ -111,7 +117,8 @@ void setup() {
|
|||||||
while (!Serial) continue;
|
while (!Serial) continue;
|
||||||
|
|
||||||
// Initialize SD library
|
// Initialize SD library
|
||||||
while (!SD.begin()) {
|
const int chipSelect = 4;
|
||||||
|
while (!SD.begin(chipSelect)) {
|
||||||
Serial.println(F("Failed to initialize SD library"));
|
Serial.println(F("Failed to initialize SD library"));
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,8 @@ void setup() {
|
|||||||
// Check HTTP status
|
// Check HTTP status
|
||||||
char status[32] = {0};
|
char status[32] = {0};
|
||||||
client.readBytesUntil('\r', status, sizeof(status));
|
client.readBytesUntil('\r', status, sizeof(status));
|
||||||
if (strcmp(status, "HTTP/1.1 200 OK") != 0) {
|
// It should be "HTTP/1.0 200 OK" or "HTTP/1.1 200 OK"
|
||||||
|
if (strcmp(status + 9, "200 OK") != 0) {
|
||||||
Serial.print(F("Unexpected response: "));
|
Serial.print(F("Unexpected response: "));
|
||||||
Serial.println(status);
|
Serial.println(status);
|
||||||
return;
|
return;
|
||||||
|
@ -5,4 +5,5 @@ make
|
|||||||
make test
|
make test
|
||||||
|
|
||||||
pip install --user cpp-coveralls 'requests[security]'
|
pip install --user cpp-coveralls 'requests[security]'
|
||||||
coveralls --exclude third-party --gcov-options '\-lp'; fi
|
pwd
|
||||||
|
coveralls --include 'src' --gcov-options '\-lp'
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
ROOT_DIR=$(dirname $0)/../../
|
ROOT_DIR=$(dirname $0)/../../
|
||||||
INCLUDE_DIR=${ROOT_DIR}/src/
|
INCLUDE_DIR=${ROOT_DIR}/src/
|
||||||
FUZZING_DIR=${ROOT_DIR}/fuzzing/
|
FUZZING_DIR=${ROOT_DIR}/extras/fuzzing/
|
||||||
CXXFLAGS="-g -fprofile-instr-generate -fcoverage-mapping -fsanitize=address,undefined,fuzzer -fno-sanitize-recover=all"
|
CXXFLAGS="-g -fprofile-instr-generate -fcoverage-mapping -fsanitize=address,undefined,fuzzer -fno-sanitize-recover=all"
|
||||||
|
|
||||||
fuzz() {
|
fuzz() {
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
pip install --user platformio
|
pip install --user platformio
|
||||||
|
|
||||||
rm -r test
|
|
||||||
|
|
||||||
case $BOARD in
|
case $BOARD in
|
||||||
uno)
|
uno)
|
||||||
platformio lib install 868 # SD library
|
platformio lib install 868 # SD library
|
@ -1,6 +1,6 @@
|
|||||||
# CAUTION: this file is invoked by https://github.com/google/oss-fuzz
|
# CAUTION: this file is invoked by https://github.com/google/oss-fuzz
|
||||||
|
|
||||||
CXXFLAGS += -I../src -DARDUINOJSON_DEBUG
|
CXXFLAGS += -I../../src -DARDUINOJSON_DEBUG
|
||||||
|
|
||||||
all: \
|
all: \
|
||||||
$(OUT)/json_fuzzer \
|
$(OUT)/json_fuzzer \
|
||||||
@ -10,7 +10,7 @@ all: \
|
|||||||
$(OUT)/msgpack_fuzzer_seed_corpus.zip \
|
$(OUT)/msgpack_fuzzer_seed_corpus.zip \
|
||||||
$(OUT)/msgpack_fuzzer.options
|
$(OUT)/msgpack_fuzzer.options
|
||||||
|
|
||||||
$(OUT)/%_fuzzer: %_fuzzer.cpp $(shell find ../src -type f)
|
$(OUT)/%_fuzzer: %_fuzzer.cpp $(shell find ../../src -type f)
|
||||||
$(CXX) $(CXXFLAGS) $< -o$@ $(LIB_FUZZING_ENGINE)
|
$(CXX) $(CXXFLAGS) $< -o$@ $(LIB_FUZZING_ENGINE)
|
||||||
|
|
||||||
$(OUT)/%_fuzzer_seed_corpus.zip: %_seed_corpus/*
|
$(OUT)/%_fuzzer_seed_corpus.zip: %_seed_corpus/*
|
@ -3,7 +3,7 @@
|
|||||||
TAG=$(git describe)
|
TAG=$(git describe)
|
||||||
OUTPUT="ArduinoJson-$TAG.zip"
|
OUTPUT="ArduinoJson-$TAG.zip"
|
||||||
|
|
||||||
cd $(dirname $0)/../..
|
cd $(dirname $0)/../../..
|
||||||
|
|
||||||
# remove existing file
|
# remove existing file
|
||||||
rm -f $OUTPUT
|
rm -f $OUTPUT
|
81
extras/scripts/build-single-header.sh
Executable file
81
extras/scripts/build-single-header.sh
Executable file
@ -0,0 +1,81 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
TAG=$(git describe)
|
||||||
|
RE_RELATIVE_INCLUDE='^#include[[:space:]]*"(.*)"'
|
||||||
|
RE_ABSOLUTE_INCLUDE='^#include[[:space:]]*<(ArduinoJson/.*)>'
|
||||||
|
RE_SYSTEM_INCLUDE='^#include[[:space:]]*<(.*)>'
|
||||||
|
RE_EMPTY='^(#pragma[[:space:]]+once)?[[:space:]]*(//.*)?$'
|
||||||
|
SRC_DIRECTORY="$(realpath "$(dirname $0)/../../src")"
|
||||||
|
|
||||||
|
|
||||||
|
declare -A INCLUDED
|
||||||
|
|
||||||
|
process()
|
||||||
|
{
|
||||||
|
local PARENT=$1
|
||||||
|
local FOLDER=$(dirname $1)
|
||||||
|
local SHOW_COMMENT=$2
|
||||||
|
while IFS= read -r LINE; do
|
||||||
|
if [[ $LINE =~ $RE_ABSOLUTE_INCLUDE ]]; then
|
||||||
|
local CHILD=${BASH_REMATCH[1]}
|
||||||
|
local CHILD_PATH
|
||||||
|
CHILD_PATH=$(realpath "$SRC_DIRECTORY/$CHILD")
|
||||||
|
echo "$PARENT -> $CHILD" >&2
|
||||||
|
if [[ ! ${INCLUDED[$CHILD_PATH]} ]]; then
|
||||||
|
INCLUDED[$CHILD_PATH]=true
|
||||||
|
process "$CHILD" false
|
||||||
|
fi
|
||||||
|
elif [[ $LINE =~ $RE_RELATIVE_INCLUDE ]]; then
|
||||||
|
local CHILD=${BASH_REMATCH[1]}
|
||||||
|
pushd "$FOLDER" > /dev/null
|
||||||
|
local CHILD_PATH
|
||||||
|
CHILD_PATH=$(realpath "$CHILD")
|
||||||
|
echo "$PARENT -> $CHILD" >&2
|
||||||
|
if [[ ! ${INCLUDED[$CHILD_PATH]} ]]; then
|
||||||
|
INCLUDED[$CHILD_PATH]=true
|
||||||
|
process "$CHILD" false
|
||||||
|
fi
|
||||||
|
popd > /dev/null
|
||||||
|
elif [[ $LINE =~ $RE_SYSTEM_INCLUDE ]]; then
|
||||||
|
local CHILD=${BASH_REMATCH[1]}
|
||||||
|
echo "$PARENT -> <$CHILD>" >&2
|
||||||
|
if [[ ! ${INCLUDED[$CHILD]} ]]; then
|
||||||
|
echo "#include <$CHILD>"
|
||||||
|
INCLUDED[$CHILD]=true
|
||||||
|
fi
|
||||||
|
elif [[ "${SHOW_COMMENT}" = "true" ]] ; then
|
||||||
|
echo "$LINE"
|
||||||
|
elif [[ ! $LINE =~ $RE_EMPTY ]]; then
|
||||||
|
echo "$LINE"
|
||||||
|
fi
|
||||||
|
done < $PARENT
|
||||||
|
}
|
||||||
|
|
||||||
|
simplify_namespaces() {
|
||||||
|
perl -p0i -e 's|\} // namespace ARDUINOJSON_NAMESPACE\r?\nnamespace ARDUINOJSON_NAMESPACE \{\r?\n||igs' "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
cd $(dirname $0)/../..
|
||||||
|
INCLUDED=()
|
||||||
|
process src/ArduinoJson.h true > ../ArduinoJson-$TAG.h
|
||||||
|
simplify_namespaces ../ArduinoJson-$TAG.h
|
||||||
|
g++ -x c++ -c -o ../smoketest.o - <<END
|
||||||
|
#include "../ArduinoJson-$TAG.h"
|
||||||
|
int main() {
|
||||||
|
StaticJsonDocument<300> doc;
|
||||||
|
deserializeJson(doc, "{}");
|
||||||
|
}
|
||||||
|
END
|
||||||
|
|
||||||
|
INCLUDED=()
|
||||||
|
process src/ArduinoJson.hpp true > ../ArduinoJson-$TAG.hpp
|
||||||
|
simplify_namespaces ../ArduinoJson-$TAG.hpp
|
||||||
|
g++ -x c++ -c -o ../smoketest.o - <<END
|
||||||
|
#include "../ArduinoJson-$TAG.hpp"
|
||||||
|
int main() {
|
||||||
|
ArduinoJson::StaticJsonDocument<300> doc;
|
||||||
|
ArduinoJson::deserializeJson(doc, "{}");
|
||||||
|
}
|
||||||
|
END
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
export PATH="$PATH:/Applications/CMake.app/Contents/bin/"
|
export PATH="$PATH:/Applications/CMake.app/Contents/bin/"
|
||||||
|
|
||||||
cd $(dirname $0)/..
|
cd $(dirname $0)/../..
|
||||||
ROOT=$(pwd)
|
ROOT=$(pwd)
|
||||||
|
|
||||||
mkdir "build"
|
mkdir "build"
|
2
scripts/publish-particle-library.sh → extras/scripts/publish-particle-library.sh
Normal file → Executable file
2
scripts/publish-particle-library.sh → extras/scripts/publish-particle-library.sh
Normal file → Executable file
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
SOURCE_DIR="$(dirname "$0")/.."
|
SOURCE_DIR="$(dirname "$0")/../.."
|
||||||
WORK_DIR=$(mktemp -d)
|
WORK_DIR=$(mktemp -d)
|
||||||
trap 'rm -rf "$WORK_DIR"' EXIT
|
trap 'rm -rf "$WORK_DIR"' EXIT
|
||||||
|
|
8
scripts/publish.sh → extras/scripts/publish.sh
Normal file → Executable file
8
scripts/publish.sh → extras/scripts/publish.sh
Normal file → Executable file
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
cd "$(dirname "$0")/.."
|
cd "$(dirname "$0")/../.."
|
||||||
|
|
||||||
VERSION="$1"
|
VERSION="$1"
|
||||||
DATE=$(date +%F)
|
DATE=$(date +%F)
|
||||||
@ -56,6 +56,6 @@ commit_new_version
|
|||||||
add_tag
|
add_tag
|
||||||
push
|
push
|
||||||
|
|
||||||
scripts/build-arduino-package.sh
|
extras/scripts/build-arduino-package.sh
|
||||||
scripts/build-single-header.sh
|
extras/scripts/build-single-header.sh
|
||||||
scripts/wandbox/publish.sh "../ArduinoJson-$TAG.h"
|
extras/scripts/wandbox/publish.sh "../ArduinoJson-$TAG.h"
|
0
scripts/wandbox/publish.sh → extras/scripts/wandbox/publish.sh
Normal file → Executable file
0
scripts/wandbox/publish.sh → extras/scripts/wandbox/publish.sh
Normal file → Executable file
@ -2,6 +2,8 @@
|
|||||||
# Copyright Benoit Blanchon 2014-2019
|
# Copyright Benoit Blanchon 2014-2019
|
||||||
# MIT License
|
# MIT License
|
||||||
|
|
||||||
|
add_subdirectory(catch)
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
|
||||||
add_compile_options(
|
add_compile_options(
|
||||||
-pedantic
|
-pedantic
|
||||||
@ -70,6 +72,7 @@ if(MSVC)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include_directories(Helpers)
|
||||||
add_subdirectory(ElementProxy)
|
add_subdirectory(ElementProxy)
|
||||||
add_subdirectory(IntegrationTests)
|
add_subdirectory(IntegrationTests)
|
||||||
add_subdirectory(JsonArray)
|
add_subdirectory(JsonArray)
|
@ -5,6 +5,7 @@
|
|||||||
add_executable(ElementProxyTests
|
add_executable(ElementProxyTests
|
||||||
add.cpp
|
add.cpp
|
||||||
clear.cpp
|
clear.cpp
|
||||||
|
compare.cpp
|
||||||
remove.cpp
|
remove.cpp
|
||||||
set.cpp
|
set.cpp
|
||||||
size.cpp
|
size.cpp
|
28
extras/tests/ElementProxy/compare.cpp
Normal file
28
extras/tests/ElementProxy/compare.cpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// ArduinoJson - arduinojson.org
|
||||||
|
// Copyright Benoit Blanchon 2014-2019
|
||||||
|
// MIT License
|
||||||
|
|
||||||
|
#include <ArduinoJson.h>
|
||||||
|
#include <catch.hpp>
|
||||||
|
|
||||||
|
using namespace ARDUINOJSON_NAMESPACE;
|
||||||
|
|
||||||
|
TEST_CASE("ElementProxy::operator==()") {
|
||||||
|
DynamicJsonDocument doc(4096);
|
||||||
|
|
||||||
|
SECTION("same value") {
|
||||||
|
doc.add(1);
|
||||||
|
doc.add(1);
|
||||||
|
|
||||||
|
REQUIRE(doc[0] == doc[1]);
|
||||||
|
REQUIRE_FALSE(doc[0] != doc[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("different values") {
|
||||||
|
doc.add(1);
|
||||||
|
doc.add(2);
|
||||||
|
|
||||||
|
REQUIRE_FALSE(doc[0] == doc[1]);
|
||||||
|
REQUIRE(doc[0] != doc[1]);
|
||||||
|
}
|
||||||
|
}
|
26
extras/tests/Helpers/CustomReader.hpp
Normal file
26
extras/tests/Helpers/CustomReader.hpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// ArduinoJson - arduinojson.org
|
||||||
|
// Copyright Benoit Blanchon 2014-2019
|
||||||
|
// MIT License
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
class CustomReader {
|
||||||
|
std::stringstream _stream;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CustomReader(const char* input) : _stream(input) {}
|
||||||
|
|
||||||
|
int read() {
|
||||||
|
return _stream.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t readBytes(char* buffer, size_t length) {
|
||||||
|
_stream.read(buffer, static_cast<std::streamsize>(length));
|
||||||
|
return static_cast<size_t>(_stream.gcount());
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CustomReader(const CustomReader&);
|
||||||
|
};
|
14
extras/tests/Helpers/Stream.h
Normal file
14
extras/tests/Helpers/Stream.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// ArduinoJson - arduinojson.org
|
||||||
|
// Copyright Benoit Blanchon 2014-2019
|
||||||
|
// MIT License
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Reproduces Arduino's Stream class
|
||||||
|
class Stream // : public Print
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~Stream() {}
|
||||||
|
virtual int read() = 0;
|
||||||
|
virtual size_t readBytes(char *buffer, size_t length) = 0;
|
||||||
|
};
|
58
extras/tests/JsonArray/isNull.cpp
Normal file
58
extras/tests/JsonArray/isNull.cpp
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
// ArduinoJson - arduinojson.org
|
||||||
|
// Copyright Benoit Blanchon 2014-2019
|
||||||
|
// MIT License
|
||||||
|
|
||||||
|
#include <ArduinoJson.h>
|
||||||
|
#include <catch.hpp>
|
||||||
|
|
||||||
|
TEST_CASE("JsonArray::isNull()") {
|
||||||
|
SECTION("returns true") {
|
||||||
|
JsonArray arr;
|
||||||
|
REQUIRE(arr.isNull() == true);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("returns false") {
|
||||||
|
DynamicJsonDocument doc(4096);
|
||||||
|
JsonArray arr = doc.to<JsonArray>();
|
||||||
|
REQUIRE(arr.isNull() == false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("JsonArrayConst::isNull()") {
|
||||||
|
SECTION("returns true") {
|
||||||
|
JsonArrayConst arr;
|
||||||
|
REQUIRE(arr.isNull() == true);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("returns false") {
|
||||||
|
DynamicJsonDocument doc(4096);
|
||||||
|
JsonArrayConst arr = doc.to<JsonArray>();
|
||||||
|
REQUIRE(arr.isNull() == false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("JsonArray::operator bool()") {
|
||||||
|
SECTION("returns false") {
|
||||||
|
JsonArray arr;
|
||||||
|
REQUIRE(static_cast<bool>(arr) == false);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("returns true") {
|
||||||
|
DynamicJsonDocument doc(4096);
|
||||||
|
JsonArray arr = doc.to<JsonArray>();
|
||||||
|
REQUIRE(static_cast<bool>(arr) == true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("JsonArrayConst::operator bool()") {
|
||||||
|
SECTION("returns false") {
|
||||||
|
JsonArrayConst arr;
|
||||||
|
REQUIRE(static_cast<bool>(arr) == false);
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("returns true") {
|
||||||
|
DynamicJsonDocument doc(4096);
|
||||||
|
JsonArrayConst arr = doc.to<JsonArray>();
|
||||||
|
REQUIRE(static_cast<bool>(arr) == true);
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user