mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 00:38:27 +01:00
Removed Print class and converted printTo() to a template method (issue #276)
This commit is contained in:
@@ -10,20 +10,12 @@
|
||||
|
||||
using namespace ArduinoJson::Internals;
|
||||
|
||||
TEST_CASE("StringBuilder") {
|
||||
char output[20];
|
||||
StaticStringBuilder sb(output, sizeof(output));
|
||||
|
||||
template <typename StringBuilder, typename String>
|
||||
void common_tests(StringBuilder& sb, const String& output) {
|
||||
SECTION("InitialState") {
|
||||
REQUIRE(std::string("") == output);
|
||||
}
|
||||
|
||||
SECTION("OverCapacity") {
|
||||
REQUIRE(19 == sb.print("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
|
||||
REQUIRE(0 == sb.print("ABC"));
|
||||
REQUIRE(std::string("ABCDEFGHIJKLMNOPQRS") == output);
|
||||
}
|
||||
|
||||
SECTION("EmptyString") {
|
||||
REQUIRE(0 == sb.print(""));
|
||||
REQUIRE(std::string("") == output);
|
||||
@@ -40,3 +32,22 @@ TEST_CASE("StringBuilder") {
|
||||
REQUIRE(std::string("ABCDEFGH") == output);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("StaticStringBuilder") {
|
||||
char output[20];
|
||||
StaticStringBuilder sb(output, sizeof(output));
|
||||
|
||||
common_tests(sb, static_cast<const char*>(output));
|
||||
|
||||
SECTION("OverCapacity") {
|
||||
REQUIRE(19 == sb.print("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
|
||||
REQUIRE(0 == sb.print("ABC"));
|
||||
REQUIRE(std::string("ABCDEFGHIJKLMNOPQRS") == output);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("DynamicStringBuilder") {
|
||||
std::string output;
|
||||
DynamicStringBuilder<std::string> sb(output);
|
||||
common_tests(sb, output);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user