Moved ancillary files to extras/ (fixes #1011)

This commit is contained in:
Benoit Blanchon
2019-09-03 15:11:05 +02:00
parent ed18e77655
commit b47ac27ac6
226 changed files with 19 additions and 54 deletions

View File

@ -0,0 +1,49 @@
// ArduinoJson - arduinojson.org
// Copyright Benoit Blanchon 2014-2019
// MIT License
#include <ArduinoJson.h>
#include <stdlib.h> // malloc, free
#include <catch.hpp>
#include <sstream>
using ARDUINOJSON_NAMESPACE::addPadding;
class SpyingAllocator {
public:
SpyingAllocator(std::ostream& log) : _log(log) {}
void* allocate(size_t n) {
_log << "A" << n;
return malloc(n);
}
void deallocate(void* p) {
_log << "F";
free(p);
}
private:
SpyingAllocator& operator=(const SpyingAllocator& src);
std::ostream& _log;
};
typedef BasicJsonDocument<SpyingAllocator> MyJsonDocument;
TEST_CASE("BasicJsonDocument") {
std::stringstream log;
SECTION("Construct/Destruct") {
{ MyJsonDocument doc(4096, log); }
REQUIRE(log.str() == "A4096F");
}
SECTION("Copy construct") {
{
MyJsonDocument doc1(4096, log);
doc1.set(std::string("The size of this string is 32!!"));
MyJsonDocument doc2(doc1);
}
REQUIRE(log.str() == "A4096A32FF");
}
}