forked from bblanchon/ArduinoJson
Improved speed of serializeXxx() when writing to a String
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
// MIT License
|
||||
|
||||
#define ARDUINOJSON_ENABLE_ARDUINO_STRING 1
|
||||
#define ARDUINOJSON_STRING_BUFFER_SIZE 5
|
||||
#include <ArduinoJson.h>
|
||||
#include <catch.hpp>
|
||||
#include "custom_string.hpp"
|
||||
@ -59,7 +60,39 @@ TEST_CASE("Writer<std::string>") {
|
||||
TEST_CASE("Writer<String>") {
|
||||
::String output;
|
||||
Writer< ::String> sb(output);
|
||||
|
||||
common_tests(sb, output);
|
||||
|
||||
SECTION("Writes characters to temporary buffer") {
|
||||
// accumulate in buffer
|
||||
sb.write('a');
|
||||
sb.write('b');
|
||||
sb.write('c');
|
||||
REQUIRE(output == "");
|
||||
|
||||
// flush when full
|
||||
sb.write('d');
|
||||
REQUIRE(output == "abcd");
|
||||
|
||||
// flush on destruction
|
||||
sb.write('e');
|
||||
sb.~Writer();
|
||||
REQUIRE(output == "abcde");
|
||||
}
|
||||
|
||||
SECTION("Writes strings to temporary buffer") {
|
||||
// accumulate in buffer
|
||||
print(sb, "abc");
|
||||
REQUIRE(output == "");
|
||||
|
||||
// flush when full, and continue to accumulate
|
||||
print(sb, "de");
|
||||
REQUIRE(output == "abcd");
|
||||
|
||||
// flush on destruction
|
||||
sb.~Writer();
|
||||
REQUIRE(output == "abcde");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Writer<custom_string>") {
|
||||
|
Reference in New Issue
Block a user