2017-11-07 20:42:50 +01:00
|
|
|
// ArduinoJson - arduinojson.org
|
2018-01-05 09:20:01 +01:00
|
|
|
// Copyright Benoit Blanchon 2014-2018
|
2017-04-18 18:22:24 +02:00
|
|
|
// MIT License
|
|
|
|
|
|
|
|
#include <ArduinoJson.h>
|
|
|
|
#include <catch.hpp>
|
|
|
|
|
|
|
|
TEST_CASE("DynamicJsonBuffer::strdup()") {
|
|
|
|
DynamicJsonBuffer buffer;
|
|
|
|
|
|
|
|
SECTION("Should return a copy") {
|
|
|
|
char original[] = "hello";
|
2018-01-14 13:49:37 +01:00
|
|
|
const char* copy = buffer.strdup(original);
|
2017-04-18 18:22:24 +02:00
|
|
|
strcpy(original, "world");
|
|
|
|
REQUIRE(std::string("hello") == copy);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Given NULL, return NULL") {
|
|
|
|
const char* original = NULL;
|
2018-01-14 13:49:37 +01:00
|
|
|
const char* copy = buffer.strdup(original);
|
2017-04-18 18:22:24 +02:00
|
|
|
REQUIRE(0 == copy);
|
|
|
|
}
|
|
|
|
}
|