-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed segmentation fault in
StaticJsonBuffer
(issue #104)
- v7.3.0
- v7.2.1
- v7.2.0
- v7.1.0
- v7.0.4
- v7.0.3
- v7.0.2
- v7.0.1
- v7.0.0
- v6.21.5
- v6.21.4
- v6.21.3
- v6.21.2
- v6.21.1
- v6.21.0
- v6.20.1
- v6.20.0
- v6.19.4
- v6.19.3
- v6.19.2
- v6.19.1
- v6.19.0
- v6.18.5
- v6.18.4
- v6.18.3
- v6.18.2
- v6.18.1
- v6.18.0
- v6.17.3
- v6.17.2
- v6.17.1
- v6.17.0
- v6.16.1
- v6.16.0
- v6.15.2
- v6.15.1
- v6.15.0
- v6.14.1
- v6.14.0
- v6.13.0
- v6.12.0
- v6.11.5
- v6.11.4
- v6.11.3
- v6.11.2
- v6.11.1
- v6.11.0
- v6.10.1
- v6.10.0
- v6.9.1
- v6.9.0
- v6.8.0-beta
- v6.7.0-beta
- v6.6.0-beta
- v6.5.0-beta
- v6.4.0-beta
- v6.3.0-beta
- v6.2.3-beta
- v6.2.2-beta
- v6.2.1-beta
- v6.2.0-beta
- v6.1.0-beta
- v6.0.1-beta
- v6.0.0-beta
- v5.13.5
- v5.13.4
- v5.13.3
- v5.13.2
- v5.13.1
- v5.13.0
- v5.12.0
- v5.11.2
- v5.11.1
- v5.11.0
- v5.10.1
- v5.10.0
- v5.9.0
- v5.8.4
- v5.8.3
- v5.8.2
- v5.8.1
- v5.8.0
- v5.7.3
- v5.7.2
- v5.7.1
- v5.7.0
- v5.6.7
- v5.6.6
- v5.6.5
- v5.6.4
- v5.6.3
- v5.6.2
- v5.6.1
- v5.6.0
- v5.5.1
- v5.5.0
- v5.4.0
- v5.3.0
- v5.2.0
- v5.1.1
- v5.1.0
- v5.1.0-beta.2
- v5.1.0-beta.1
- v5.0.8
- v5.0.7
- v5.0.6
- v5.0.5
- v5.0.4
- v5.0.3
- v5.0.2
Showing
6 changed files
with
97 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright Benoit Blanchon 2014-2015 | ||
// MIT License | ||
// | ||
// Arduino JSON library | ||
// https://github.com/bblanchon/ArduinoJson | ||
|
||
#include <gtest/gtest.h> | ||
#define ARDUINOJSON_ENABLE_STD_STREAM | ||
#include <ArduinoJson.h> | ||
|
||
#define SOURCE "{\"mqtt.host\":\"mqtt.test.com\",\"mqtt.port\":1883}" | ||
|
||
#define SIZE_WITH_COPY (sizeof(SOURCE) + JSON_OBJECT_SIZE(2)) | ||
#define SIZE_WITHOUT_COPY (JSON_OBJECT_SIZE(2)) | ||
|
||
template <int N, typename S> | ||
void mustSucceedWith(S source) { | ||
StaticJsonBuffer<N> jsonBuffer; | ||
ASSERT_TRUE(jsonBuffer.parseObject(source).success()); | ||
} | ||
|
||
template <int N, typename S> | ||
void mustFailWith(S source) { | ||
StaticJsonBuffer<N> jsonBuffer; | ||
ASSERT_FALSE(jsonBuffer.parseObject(source).success()); | ||
} | ||
|
||
TEST(Issue104, CharPtrSucceeds) { | ||
char source[] = SOURCE; | ||
mustSucceedWith<SIZE_WITHOUT_COPY, char *>(source); | ||
} | ||
|
||
TEST(Issue104, CharPtrFails) { | ||
char source[] = SOURCE; | ||
mustFailWith<SIZE_WITHOUT_COPY - 1, char *>(source); | ||
} | ||
|
||
TEST(Issue104, ConstCharPtrSucceeds) { | ||
mustSucceedWith<SIZE_WITH_COPY, const char *>(SOURCE); | ||
} | ||
|
||
TEST(Issue104, ConstCharPtrFails) { | ||
mustFailWith<SIZE_WITH_COPY - 1, const char *>(SOURCE); | ||
} | ||
|
||
TEST(Issue104, StringSucceeds) { | ||
mustSucceedWith<SIZE_WITH_COPY, const String &>(SOURCE); | ||
} | ||
|
||
TEST(Issue104, StringFails) { | ||
mustFailWith<SIZE_WITH_COPY - 1, const String &>(SOURCE); | ||
} | ||
|
||
TEST(Issue104, TooSmallForStrDup) { | ||
mustFailWith<sizeof(SOURCE) - 1, const char *>(SOURCE); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters