mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-16 12:02:14 +02:00
Tests: replace constants with sizeofString(n)
This commit is contained in:
@ -8,6 +8,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
using ArduinoJson::detail::sizeofArray;
|
using ArduinoJson::detail::sizeofArray;
|
||||||
|
using ArduinoJson::detail::sizeofString;
|
||||||
|
|
||||||
TEST_CASE("string_view") {
|
TEST_CASE("string_view") {
|
||||||
JsonDocument doc(256);
|
JsonDocument doc(256);
|
||||||
@ -55,16 +56,18 @@ TEST_CASE("string_view") {
|
|||||||
|
|
||||||
SECTION("String deduplication") {
|
SECTION("String deduplication") {
|
||||||
doc.add(std::string_view("example one", 7));
|
doc.add(std::string_view("example one", 7));
|
||||||
REQUIRE(doc.memoryUsage() == sizeofArray(1) + 8);
|
REQUIRE(doc.memoryUsage() == sizeofArray(1) + sizeofString(7));
|
||||||
|
|
||||||
doc.add(std::string_view("example two", 7));
|
doc.add(std::string_view("example two", 7));
|
||||||
REQUIRE(doc.memoryUsage() == sizeofArray(2) + 8);
|
REQUIRE(doc.memoryUsage() == sizeofArray(2) + sizeofString(7));
|
||||||
|
|
||||||
doc.add(std::string_view("example\0tree", 12));
|
doc.add(std::string_view("example\0tree", 12));
|
||||||
REQUIRE(doc.memoryUsage() == sizeofArray(3) + 21);
|
REQUIRE(doc.memoryUsage() ==
|
||||||
|
sizeofArray(3) + sizeofString(7) + sizeofString(12));
|
||||||
|
|
||||||
doc.add(std::string_view("example\0tree and a half", 12));
|
doc.add(std::string_view("example\0tree and a half", 12));
|
||||||
REQUIRE(doc.memoryUsage() == sizeofArray(4) + 21);
|
REQUIRE(doc.memoryUsage() ==
|
||||||
|
sizeofArray(4) + sizeofString(7) + sizeofString(12));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("as<std::string_view>()") {
|
SECTION("as<std::string_view>()") {
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
using ArduinoJson::detail::sizeofArray;
|
using ArduinoJson::detail::sizeofArray;
|
||||||
using ArduinoJson::detail::sizeofObject;
|
using ArduinoJson::detail::sizeofObject;
|
||||||
|
using ArduinoJson::detail::sizeofString;
|
||||||
|
|
||||||
TEST_CASE("JsonArray::memoryUsage()") {
|
TEST_CASE("JsonArray::memoryUsage()") {
|
||||||
JsonDocument doc(4096);
|
JsonDocument doc(4096);
|
||||||
@ -28,7 +29,7 @@ TEST_CASE("JsonArray::memoryUsage()") {
|
|||||||
|
|
||||||
SECTION("includes the size of the string") {
|
SECTION("includes the size of the string") {
|
||||||
arr.add(std::string("hello"));
|
arr.add(std::string("hello"));
|
||||||
REQUIRE(arr.memoryUsage() == sizeofArray(1) + 6);
|
REQUIRE(arr.memoryUsage() == sizeofArray(1) + sizeofString(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("includes the size of the nested array") {
|
SECTION("includes the size of the nested array") {
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
using ArduinoJson::detail::sizeofArray;
|
using ArduinoJson::detail::sizeofArray;
|
||||||
using ArduinoJson::detail::sizeofObject;
|
using ArduinoJson::detail::sizeofObject;
|
||||||
|
using ArduinoJson::detail::sizeofString;
|
||||||
|
|
||||||
TEST_CASE("Filtering") {
|
TEST_CASE("Filtering") {
|
||||||
struct TestCase {
|
struct TestCase {
|
||||||
@ -46,7 +47,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"abcdefg\":\"hijklmn\"}",
|
"{\"abcdefg\":\"hijklmn\"}",
|
||||||
sizeofObject(1) + 16
|
sizeofObject(1) + 2*sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"{\"hello\":\"world\"}",
|
"{\"hello\":\"world\"}",
|
||||||
@ -72,7 +73,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":null}",
|
"{\"example\":null}",
|
||||||
sizeofObject(1) + 8
|
sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Member is a number, but filter wants an array
|
// Member is a number, but filter wants an array
|
||||||
@ -81,7 +82,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":null}",
|
"{\"example\":null}",
|
||||||
sizeofObject(1) + 8
|
sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Input is an array, but filter wants an object
|
// Input is an array, but filter wants an object
|
||||||
@ -117,7 +118,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":42}",
|
"{\"example\":42}",
|
||||||
sizeofObject(1) + 8
|
sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// skip a float
|
// skip a float
|
||||||
@ -126,7 +127,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":42}",
|
"{\"example\":42}",
|
||||||
sizeofObject(1) + 8
|
sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// skip false
|
// skip false
|
||||||
@ -135,7 +136,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":42}",
|
"{\"example\":42}",
|
||||||
sizeofObject(1) + 8
|
sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// skip true
|
// skip true
|
||||||
@ -144,7 +145,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":42}",
|
"{\"example\":42}",
|
||||||
sizeofObject(1) + 8
|
sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// skip null
|
// skip null
|
||||||
@ -153,7 +154,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":42}",
|
"{\"example\":42}",
|
||||||
sizeofObject(1) + 8
|
sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// can skip a double-quoted string
|
// can skip a double-quoted string
|
||||||
@ -162,7 +163,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":42}",
|
"{\"example\":42}",
|
||||||
sizeofObject(1) + 8
|
sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// can skip a single-quoted string
|
// can skip a single-quoted string
|
||||||
@ -171,7 +172,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":42}",
|
"{\"example\":42}",
|
||||||
sizeofObject(1) + 8
|
sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// can skip an empty array
|
// can skip an empty array
|
||||||
@ -180,7 +181,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":42}",
|
"{\"example\":42}",
|
||||||
sizeofObject(1) + 8
|
sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// can skip an empty array with spaces in it
|
// can skip an empty array with spaces in it
|
||||||
@ -189,7 +190,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":42}",
|
"{\"example\":42}",
|
||||||
sizeofObject(1) + 8
|
sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// can skip an array
|
// can skip an array
|
||||||
@ -198,7 +199,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":42}",
|
"{\"example\":42}",
|
||||||
sizeofObject(1) + 8
|
sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// can skip an array with spaces in it
|
// can skip an array with spaces in it
|
||||||
@ -207,7 +208,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":42}",
|
"{\"example\":42}",
|
||||||
sizeofObject(1) + 8
|
sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// can skip an empty object
|
// can skip an empty object
|
||||||
@ -216,7 +217,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":42}",
|
"{\"example\":42}",
|
||||||
sizeofObject(1) + 8
|
sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// can skip an empty object with spaces in it
|
// can skip an empty object with spaces in it
|
||||||
@ -225,7 +226,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":42}",
|
"{\"example\":42}",
|
||||||
sizeofObject(1) + 8
|
sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// can skip an object
|
// can skip an object
|
||||||
@ -234,7 +235,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":42}",
|
"{\"example\":42}",
|
||||||
sizeofObject(1) + 8
|
sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// skip an object with spaces in it
|
// skip an object with spaces in it
|
||||||
@ -243,7 +244,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":42}",
|
"{\"example\":42}",
|
||||||
sizeofObject(1) + 8
|
sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"{\"an_integer\": 0,\"example\":{\"type\":\"int\",\"outcome\":42}}",
|
"{\"an_integer\": 0,\"example\":{\"type\":\"int\",\"outcome\":42}}",
|
||||||
@ -251,7 +252,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":{\"outcome\":42}}",
|
"{\"example\":{\"outcome\":42}}",
|
||||||
2 * sizeofObject(1) + 16
|
2 * sizeofObject(1) + 2*sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// wildcard
|
// wildcard
|
||||||
@ -260,7 +261,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":{\"outcome\":42}}",
|
"{\"example\":{\"outcome\":42}}",
|
||||||
2 * sizeofObject(1) + 16
|
2 * sizeofObject(1) + 2*sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// exclusion filter (issue #1628)
|
// exclusion filter (issue #1628)
|
||||||
@ -269,7 +270,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"{\"example\":1}",
|
"{\"example\":1}",
|
||||||
sizeofObject(1) + 8
|
sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// only the first element of array counts
|
// only the first element of array counts
|
||||||
@ -296,7 +297,7 @@ TEST_CASE("Filtering") {
|
|||||||
10,
|
10,
|
||||||
DeserializationError::Ok,
|
DeserializationError::Ok,
|
||||||
"[{\"example\":1},{\"example\":3}]",
|
"[{\"example\":1},{\"example\":3}]",
|
||||||
sizeofArray(2) + 2 * sizeofObject(1) + 8
|
sizeofArray(2) + 2 * sizeofObject(1) + sizeofString(7)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"[',2,3]",
|
"[',2,3]",
|
||||||
|
@ -97,7 +97,7 @@ TEST_CASE("Invalid JSON string") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Not enough room to save the key") {
|
TEST_CASE("Not enough room to save the key") {
|
||||||
JsonDocument doc(sizeofObject(1) + 8);
|
JsonDocument doc(sizeofObject(1) + sizeofString(7));
|
||||||
|
|
||||||
SECTION("Quoted string") {
|
SECTION("Quoted string") {
|
||||||
REQUIRE(deserializeJson(doc, "{\"example\":1}") ==
|
REQUIRE(deserializeJson(doc, "{\"example\":1}") ==
|
||||||
@ -139,7 +139,7 @@ TEST_CASE("Deduplicate values") {
|
|||||||
JsonDocument doc(1024);
|
JsonDocument doc(1024);
|
||||||
deserializeJson(doc, "[\"example\",\"example\"]");
|
deserializeJson(doc, "[\"example\",\"example\"]");
|
||||||
|
|
||||||
CHECK(doc.memoryUsage() == sizeofArray(2) + 8);
|
CHECK(doc.memoryUsage() == sizeofArray(2) + sizeofString(7));
|
||||||
CHECK(doc[0].as<const char*>() == doc[1].as<const char*>());
|
CHECK(doc[0].as<const char*>() == doc[1].as<const char*>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +147,8 @@ TEST_CASE("Deduplicate keys") {
|
|||||||
JsonDocument doc(1024);
|
JsonDocument doc(1024);
|
||||||
deserializeJson(doc, "[{\"example\":1},{\"example\":2}]");
|
deserializeJson(doc, "[{\"example\":1},{\"example\":2}]");
|
||||||
|
|
||||||
CHECK(doc.memoryUsage() == 2 * sizeofObject(1) + sizeofArray(2) + 8);
|
CHECK(doc.memoryUsage() ==
|
||||||
|
2 * sizeofObject(1) + sizeofArray(2) + sizeofString(7));
|
||||||
|
|
||||||
const char* key1 = doc[0].as<JsonObject>().begin()->key().c_str();
|
const char* key1 = doc[0].as<JsonObject>().begin()->key().c_str();
|
||||||
const char* key2 = doc[1].as<JsonObject>().begin()->key().c_str();
|
const char* key2 = doc[1].as<JsonObject>().begin()->key().c_str();
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <catch.hpp>
|
#include <catch.hpp>
|
||||||
|
|
||||||
typedef ArduinoJson::detail::ElementProxy<JsonDocument&> ElementProxy;
|
typedef ArduinoJson::detail::ElementProxy<JsonDocument&> ElementProxy;
|
||||||
|
using ArduinoJson::detail::sizeofString;
|
||||||
|
|
||||||
TEST_CASE("ElementProxy::add()") {
|
TEST_CASE("ElementProxy::add()") {
|
||||||
JsonDocument doc(4096);
|
JsonDocument doc(4096);
|
||||||
@ -199,7 +200,7 @@ TEST_CASE("ElementProxy::memoryUsage()") {
|
|||||||
|
|
||||||
SECTION("returns size for string") {
|
SECTION("returns size for string") {
|
||||||
ep.set(std::string("hello"));
|
ep.set(std::string("hello"));
|
||||||
REQUIRE(ep.memoryUsage() == 6);
|
REQUIRE(ep.memoryUsage() == sizeofString(5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
using ArduinoJson::detail::sizeofArray;
|
using ArduinoJson::detail::sizeofArray;
|
||||||
using ArduinoJson::detail::sizeofObject;
|
using ArduinoJson::detail::sizeofObject;
|
||||||
|
using ArduinoJson::detail::sizeofString;
|
||||||
|
|
||||||
typedef ArduinoJson::detail::MemberProxy<JsonDocument&, const char*>
|
typedef ArduinoJson::detail::MemberProxy<JsonDocument&, const char*>
|
||||||
MemberProxy;
|
MemberProxy;
|
||||||
@ -248,7 +249,7 @@ TEST_CASE("MemberProxy::memoryUsage()") {
|
|||||||
|
|
||||||
SECTION("return the size for a string") {
|
SECTION("return the size for a string") {
|
||||||
mp.set(std::string("hello"));
|
mp.set(std::string("hello"));
|
||||||
REQUIRE(mp.memoryUsage() == 6);
|
REQUIRE(mp.memoryUsage() == sizeofString(5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +343,8 @@ TEST_CASE("Deduplicate keys") {
|
|||||||
doc[0][std::string("example")] = 1;
|
doc[0][std::string("example")] = 1;
|
||||||
doc[1][std::string("example")] = 2;
|
doc[1][std::string("example")] = 2;
|
||||||
|
|
||||||
CHECK(doc.memoryUsage() == sizeofArray(2) + 2 * sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() ==
|
||||||
|
sizeofArray(2) + 2 * sizeofObject(1) + sizeofString(7));
|
||||||
|
|
||||||
const char* key1 = doc[0].as<JsonObject>().begin()->key().c_str();
|
const char* key1 = doc[0].as<JsonObject>().begin()->key().c_str();
|
||||||
const char* key2 = doc[1].as<JsonObject>().begin()->key().c_str();
|
const char* key2 = doc[1].as<JsonObject>().begin()->key().c_str();
|
||||||
@ -354,7 +356,8 @@ TEST_CASE("Deduplicate keys") {
|
|||||||
doc[0][key] = 1;
|
doc[0][key] = 1;
|
||||||
doc[1][key] = 2;
|
doc[1][key] = 2;
|
||||||
|
|
||||||
CHECK(doc.memoryUsage() == sizeofArray(2) + 2 * sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() ==
|
||||||
|
sizeofArray(2) + 2 * sizeofObject(1) + sizeofString(7));
|
||||||
|
|
||||||
const char* key1 = doc[0].as<JsonObject>().begin()->key().c_str();
|
const char* key1 = doc[0].as<JsonObject>().begin()->key().c_str();
|
||||||
const char* key2 = doc[1].as<JsonObject>().begin()->key().c_str();
|
const char* key2 = doc[1].as<JsonObject>().begin()->key().c_str();
|
||||||
@ -365,7 +368,8 @@ TEST_CASE("Deduplicate keys") {
|
|||||||
doc[0][String("example")] = 1;
|
doc[0][String("example")] = 1;
|
||||||
doc[1][String("example")] = 2;
|
doc[1][String("example")] = 2;
|
||||||
|
|
||||||
CHECK(doc.memoryUsage() == sizeofArray(2) + 2 * sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() ==
|
||||||
|
sizeofArray(2) + 2 * sizeofObject(1) + sizeofString(7));
|
||||||
|
|
||||||
const char* key1 = doc[0].as<JsonObject>().begin()->key().c_str();
|
const char* key1 = doc[0].as<JsonObject>().begin()->key().c_str();
|
||||||
const char* key2 = doc[1].as<JsonObject>().begin()->key().c_str();
|
const char* key2 = doc[1].as<JsonObject>().begin()->key().c_str();
|
||||||
@ -376,7 +380,8 @@ TEST_CASE("Deduplicate keys") {
|
|||||||
doc[0][F("example")] = 1;
|
doc[0][F("example")] = 1;
|
||||||
doc[1][F("example")] = 2;
|
doc[1][F("example")] = 2;
|
||||||
|
|
||||||
CHECK(doc.memoryUsage() == sizeofArray(2) + 2 * sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() ==
|
||||||
|
sizeofArray(2) + 2 * sizeofObject(1) + sizeofString(7));
|
||||||
|
|
||||||
const char* key1 = doc[0].as<JsonObject>().begin()->key().c_str();
|
const char* key1 = doc[0].as<JsonObject>().begin()->key().c_str();
|
||||||
const char* key2 = doc[1].as<JsonObject>().begin()->key().c_str();
|
const char* key2 = doc[1].as<JsonObject>().begin()->key().c_str();
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <catch.hpp>
|
#include <catch.hpp>
|
||||||
|
|
||||||
using ArduinoJson::detail::sizeofArray;
|
using ArduinoJson::detail::sizeofArray;
|
||||||
|
using ArduinoJson::detail::sizeofString;
|
||||||
|
|
||||||
TEST_CASE("JsonDocument::add()") {
|
TEST_CASE("JsonDocument::add()") {
|
||||||
JsonDocument doc(4096);
|
JsonDocument doc(4096);
|
||||||
@ -31,7 +32,7 @@ TEST_CASE("JsonDocument::add()") {
|
|||||||
doc.add(std::string("example"));
|
doc.add(std::string("example"));
|
||||||
doc.add(std::string("example"));
|
doc.add(std::string("example"));
|
||||||
|
|
||||||
CHECK(doc.memoryUsage() == sizeofArray(2) + 8);
|
CHECK(doc.memoryUsage() == sizeofArray(2) + sizeofString(7));
|
||||||
CHECK(doc[0].as<const char*>() == doc[1].as<const char*>());
|
CHECK(doc[0].as<const char*>() == doc[1].as<const char*>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ TEST_CASE("JsonDocument::add()") {
|
|||||||
doc.add(value);
|
doc.add(value);
|
||||||
doc.add(value);
|
doc.add(value);
|
||||||
|
|
||||||
CHECK(doc.memoryUsage() == sizeofArray(2) + 8);
|
CHECK(doc.memoryUsage() == sizeofArray(2) + sizeofString(7));
|
||||||
CHECK(doc[0].as<const char*>() == doc[1].as<const char*>());
|
CHECK(doc[0].as<const char*>() == doc[1].as<const char*>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ TEST_CASE("JsonDocument::add()") {
|
|||||||
doc.add(String("example"));
|
doc.add(String("example"));
|
||||||
doc.add(String("example"));
|
doc.add(String("example"));
|
||||||
|
|
||||||
CHECK(doc.memoryUsage() == sizeofArray(2) + 8);
|
CHECK(doc.memoryUsage() == sizeofArray(2) + sizeofString(7));
|
||||||
CHECK(doc[0].as<const char*>() == doc[1].as<const char*>());
|
CHECK(doc[0].as<const char*>() == doc[1].as<const char*>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ TEST_CASE("JsonDocument::add()") {
|
|||||||
doc.add(F("example"));
|
doc.add(F("example"));
|
||||||
doc.add(F("example"));
|
doc.add(F("example"));
|
||||||
|
|
||||||
CHECK(doc.memoryUsage() == sizeofArray(2) + 8);
|
CHECK(doc.memoryUsage() == sizeofArray(2) + sizeofString(7));
|
||||||
CHECK(doc[0].as<const char*>() == doc[1].as<const char*>());
|
CHECK(doc[0].as<const char*>() == doc[1].as<const char*>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "Allocators.hpp"
|
#include "Allocators.hpp"
|
||||||
|
|
||||||
using ArduinoJson::detail::sizeofObject;
|
using ArduinoJson::detail::sizeofObject;
|
||||||
|
using ArduinoJson::detail::sizeofString;
|
||||||
|
|
||||||
TEST_CASE("JsonDocument::garbageCollect()") {
|
TEST_CASE("JsonDocument::garbageCollect()") {
|
||||||
ControllableAllocator controllableAllocator;
|
ControllableAllocator controllableAllocator;
|
||||||
@ -18,13 +19,13 @@ TEST_CASE("JsonDocument::garbageCollect()") {
|
|||||||
|
|
||||||
SECTION("when allocation succeeds") {
|
SECTION("when allocation succeeds") {
|
||||||
deserializeJson(doc, "{\"blanket\":1,\"dancing\":2}");
|
deserializeJson(doc, "{\"blanket\":1,\"dancing\":2}");
|
||||||
REQUIRE(doc.memoryUsage() == sizeofObject(2) + 16);
|
REQUIRE(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
doc.remove("blanket");
|
doc.remove("blanket");
|
||||||
|
|
||||||
bool result = doc.garbageCollect();
|
bool result = doc.garbageCollect();
|
||||||
|
|
||||||
REQUIRE(result == true);
|
REQUIRE(result == true);
|
||||||
REQUIRE(doc.memoryUsage() == sizeofObject(1) + 8);
|
REQUIRE(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
REQUIRE(doc.as<std::string>() == "{\"dancing\":2}");
|
REQUIRE(doc.as<std::string>() == "{\"dancing\":2}");
|
||||||
REQUIRE(spyingAllocator.log() == AllocatorLog()
|
REQUIRE(spyingAllocator.log() == AllocatorLog()
|
||||||
<< AllocatorLog::Allocate(4096)
|
<< AllocatorLog::Allocate(4096)
|
||||||
@ -34,14 +35,14 @@ TEST_CASE("JsonDocument::garbageCollect()") {
|
|||||||
|
|
||||||
SECTION("when allocation fails") {
|
SECTION("when allocation fails") {
|
||||||
deserializeJson(doc, "{\"blanket\":1,\"dancing\":2}");
|
deserializeJson(doc, "{\"blanket\":1,\"dancing\":2}");
|
||||||
REQUIRE(doc.memoryUsage() == sizeofObject(2) + 16);
|
REQUIRE(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
doc.remove("blanket");
|
doc.remove("blanket");
|
||||||
controllableAllocator.disable();
|
controllableAllocator.disable();
|
||||||
|
|
||||||
bool result = doc.garbageCollect();
|
bool result = doc.garbageCollect();
|
||||||
|
|
||||||
REQUIRE(result == false);
|
REQUIRE(result == false);
|
||||||
REQUIRE(doc.memoryUsage() == sizeofObject(2) + 16);
|
REQUIRE(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
REQUIRE(doc.as<std::string>() == "{\"dancing\":2}");
|
REQUIRE(doc.as<std::string>() == "{\"dancing\":2}");
|
||||||
|
|
||||||
REQUIRE(spyingAllocator.log() == AllocatorLog()
|
REQUIRE(spyingAllocator.log() == AllocatorLog()
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <catch.hpp>
|
#include <catch.hpp>
|
||||||
|
|
||||||
using ArduinoJson::detail::sizeofArray;
|
using ArduinoJson::detail::sizeofArray;
|
||||||
|
using ArduinoJson::detail::sizeofString;
|
||||||
|
|
||||||
TEST_CASE("JsonDocument::overflowed()") {
|
TEST_CASE("JsonDocument::overflowed()") {
|
||||||
SECTION("returns false on a fresh object") {
|
SECTION("returns false on a fresh object") {
|
||||||
@ -32,7 +33,7 @@ TEST_CASE("JsonDocument::overflowed()") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SECTION("returns false after a successful string copy") {
|
SECTION("returns false after a successful string copy") {
|
||||||
JsonDocument doc(sizeofArray(1) + 8);
|
JsonDocument doc(sizeofArray(1) + sizeofString(7));
|
||||||
doc.add(std::string("example"));
|
doc.add(std::string("example"));
|
||||||
CHECK(doc.overflowed() == false);
|
CHECK(doc.overflowed() == false);
|
||||||
}
|
}
|
||||||
@ -50,7 +51,7 @@ TEST_CASE("JsonDocument::overflowed()") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SECTION("returns false after a successful deserialization") {
|
SECTION("returns false after a successful deserialization") {
|
||||||
JsonDocument doc(sizeofArray(1) + 8);
|
JsonDocument doc(sizeofArray(1) + sizeofString(7));
|
||||||
deserializeJson(doc, "[\"example\"]");
|
deserializeJson(doc, "[\"example\"]");
|
||||||
CHECK(doc.overflowed() == false);
|
CHECK(doc.overflowed() == false);
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ TEST_CASE("JsonDocument::shrinkToFit()") {
|
|||||||
|
|
||||||
SECTION("unaligned") {
|
SECTION("unaligned") {
|
||||||
doc.add(std::string("?")); // two bytes in the string pool
|
doc.add(std::string("?")); // two bytes in the string pool
|
||||||
REQUIRE(doc.memoryUsage() == sizeofObject(1) + 2);
|
REQUIRE(doc.memoryUsage() == sizeofObject(1) + sizeofString(1));
|
||||||
|
|
||||||
doc.shrinkToFit();
|
doc.shrinkToFit();
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
using ArduinoJson::detail::sizeofArray;
|
using ArduinoJson::detail::sizeofArray;
|
||||||
using ArduinoJson::detail::sizeofObject;
|
using ArduinoJson::detail::sizeofObject;
|
||||||
|
using ArduinoJson::detail::sizeofString;
|
||||||
|
|
||||||
TEST_CASE("JsonObject::memoryUsage()") {
|
TEST_CASE("JsonObject::memoryUsage()") {
|
||||||
JsonDocument doc(4096);
|
JsonDocument doc(4096);
|
||||||
@ -29,7 +30,7 @@ TEST_CASE("JsonObject::memoryUsage()") {
|
|||||||
|
|
||||||
SECTION("includes the size of the key") {
|
SECTION("includes the size of the key") {
|
||||||
obj[std::string("hello")] = 42;
|
obj[std::string("hello")] = 42;
|
||||||
REQUIRE(obj.memoryUsage() == sizeofObject(1) + 6);
|
REQUIRE(obj.memoryUsage() == sizeofObject(1) + sizeofString(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("includes the size of the nested array") {
|
SECTION("includes the size of the nested array") {
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include <catch.hpp>
|
#include <catch.hpp>
|
||||||
|
|
||||||
|
using ArduinoJson::detail::sizeofString;
|
||||||
|
|
||||||
TEST_CASE("serialize JsonArray to std::string") {
|
TEST_CASE("serialize JsonArray to std::string") {
|
||||||
JsonDocument doc(4096);
|
JsonDocument doc(4096);
|
||||||
JsonArray array = doc.to<JsonArray>();
|
JsonArray array = doc.to<JsonArray>();
|
||||||
@ -49,7 +51,7 @@ TEST_CASE("serialize JsonObject to std::string") {
|
|||||||
TEST_CASE("serialize an std::string containing a NUL") {
|
TEST_CASE("serialize an std::string containing a NUL") {
|
||||||
JsonDocument doc(256);
|
JsonDocument doc(256);
|
||||||
doc.set(std::string("hello\0world", 11));
|
doc.set(std::string("hello\0world", 11));
|
||||||
CHECK(doc.memoryUsage() == 12);
|
CHECK(doc.memoryUsage() == sizeofString(11));
|
||||||
|
|
||||||
std::string json;
|
std::string json;
|
||||||
serializeJson(doc, json);
|
serializeJson(doc, json);
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
using ArduinoJson::detail::sizeofArray;
|
using ArduinoJson::detail::sizeofArray;
|
||||||
using ArduinoJson::detail::sizeofObject;
|
using ArduinoJson::detail::sizeofObject;
|
||||||
|
using ArduinoJson::detail::sizeofString;
|
||||||
|
|
||||||
TEST_CASE("JsonVariant::memoryUsage()") {
|
TEST_CASE("JsonVariant::memoryUsage()") {
|
||||||
JsonDocument doc(4096);
|
JsonDocument doc(4096);
|
||||||
@ -32,13 +33,13 @@ TEST_CASE("JsonVariant::memoryUsage()") {
|
|||||||
|
|
||||||
SECTION("returns size of owned string") {
|
SECTION("returns size of owned string") {
|
||||||
var.set(std::string("hello"));
|
var.set(std::string("hello"));
|
||||||
REQUIRE(var.memoryUsage() == 6);
|
REQUIRE(var.memoryUsage() == sizeofString(5));
|
||||||
REQUIRE(var.memoryUsage() == doc.memoryUsage());
|
REQUIRE(var.memoryUsage() == doc.memoryUsage());
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("returns size of owned raw") {
|
SECTION("returns size of owned raw") {
|
||||||
var.set(serialized(std::string("hello")));
|
var.set(serialized(std::string("hello")));
|
||||||
REQUIRE(var.memoryUsage() == 6);
|
REQUIRE(var.memoryUsage() == sizeofString(5));
|
||||||
REQUIRE(var.memoryUsage() == doc.memoryUsage());
|
REQUIRE(var.memoryUsage() == doc.memoryUsage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ TEST_CASE("StringCopier::save() deduplicates strings") {
|
|||||||
|
|
||||||
REQUIRE(s1 == s3);
|
REQUIRE(s1 == s3);
|
||||||
REQUIRE(s2 != s3);
|
REQUIRE(s2 != s3);
|
||||||
REQUIRE(pool.size() == 12);
|
REQUIRE(pool.size() == 2 * sizeofString(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Requires terminator") {
|
SECTION("Requires terminator") {
|
||||||
@ -77,7 +77,7 @@ TEST_CASE("StringCopier::save() deduplicates strings") {
|
|||||||
const char* s2 = addStringToPool(pool, "hello");
|
const char* s2 = addStringToPool(pool, "hello");
|
||||||
|
|
||||||
REQUIRE(s2 != s1);
|
REQUIRE(s2 != s1);
|
||||||
REQUIRE(pool.size() == 12 + 6);
|
REQUIRE(pool.size() == sizeofString(11) + sizeofString(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Don't overrun") {
|
SECTION("Don't overrun") {
|
||||||
@ -85,6 +85,6 @@ TEST_CASE("StringCopier::save() deduplicates strings") {
|
|||||||
const char* s2 = addStringToPool(pool, "wor");
|
const char* s2 = addStringToPool(pool, "wor");
|
||||||
|
|
||||||
REQUIRE(s2 != s1);
|
REQUIRE(s2 != s1);
|
||||||
REQUIRE(pool.size() == 12 + 4);
|
REQUIRE(pool.size() == sizeofString(11) + sizeofString(3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ TEST_CASE("MemoryPool::clear()") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Discards allocated strings") {
|
SECTION("Discards allocated strings") {
|
||||||
pool.saveString(adaptString(const_cast<char*>("123456789")));
|
pool.saveString(adaptString("123456789"));
|
||||||
REQUIRE(pool.size() == 10);
|
REQUIRE(pool.size() == sizeofString(9));
|
||||||
|
|
||||||
pool.clear();
|
pool.clear();
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
using namespace ArduinoJson::detail;
|
using namespace ArduinoJson::detail;
|
||||||
|
|
||||||
static const char* saveString(MemoryPool& pool, const char* s) {
|
static const char* saveString(MemoryPool& pool, const char* s) {
|
||||||
return pool.saveString(adaptString(const_cast<char*>(s)));
|
return pool.saveString(adaptString(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* saveString(MemoryPool& pool, const char* s, size_t n) {
|
static const char* saveString(MemoryPool& pool, const char* s, size_t n) {
|
||||||
@ -25,21 +25,20 @@ TEST_CASE("MemoryPool::saveString()") {
|
|||||||
const char* a = saveString(pool, "hello");
|
const char* a = saveString(pool, "hello");
|
||||||
const char* b = saveString(pool, "world");
|
const char* b = saveString(pool, "world");
|
||||||
REQUIRE(a != b);
|
REQUIRE(a != b);
|
||||||
REQUIRE(pool.size() == 6 + 6);
|
REQUIRE(pool.size() == 2 * sizeofString(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Deduplicates identical strings") {
|
SECTION("Deduplicates identical strings") {
|
||||||
const char* a = saveString(pool, "hello");
|
const char* a = saveString(pool, "hello");
|
||||||
const char* b = saveString(pool, "hello");
|
const char* b = saveString(pool, "hello");
|
||||||
REQUIRE(a == b);
|
REQUIRE(a == b);
|
||||||
REQUIRE(pool.size() == 6);
|
REQUIRE(pool.size() == sizeofString(5));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Deduplicates identical strings that contain NUL") {
|
SECTION("Deduplicates identical strings that contain NUL") {
|
||||||
const char* a = saveString(pool, "hello\0world", 11);
|
const char* a = saveString(pool, "hello\0world", 11);
|
||||||
const char* b = saveString(pool, "hello\0world", 11);
|
const char* b = saveString(pool, "hello\0world", 11);
|
||||||
REQUIRE(a == b);
|
REQUIRE(a == b);
|
||||||
REQUIRE(pool.size() == 12);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Reuse part of a string if it ends with NUL") {
|
SECTION("Reuse part of a string if it ends with NUL") {
|
||||||
@ -47,13 +46,14 @@ TEST_CASE("MemoryPool::saveString()") {
|
|||||||
const char* b = saveString(pool, "hello");
|
const char* b = saveString(pool, "hello");
|
||||||
REQUIRE(a == b);
|
REQUIRE(a == b);
|
||||||
REQUIRE(pool.size() == 12);
|
REQUIRE(pool.size() == 12);
|
||||||
|
REQUIRE(pool.size() == sizeofString(11));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Don't stop on first NUL") {
|
SECTION("Don't stop on first NUL") {
|
||||||
const char* a = saveString(pool, "hello");
|
const char* a = saveString(pool, "hello");
|
||||||
const char* b = saveString(pool, "hello\0world", 11);
|
const char* b = saveString(pool, "hello\0world", 11);
|
||||||
REQUIRE(a != b);
|
REQUIRE(a != b);
|
||||||
REQUIRE(pool.size() == 18);
|
REQUIRE(pool.size() == sizeofString(5) + sizeofString(11));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Returns NULL when full") {
|
SECTION("Returns NULL when full") {
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
|
|
||||||
using ArduinoJson::detail::sizeofArray;
|
using ArduinoJson::detail::sizeofArray;
|
||||||
|
using ArduinoJson::detail::sizeofString;
|
||||||
|
|
||||||
struct PrintOneCharacterAtATime {
|
struct PrintOneCharacterAtATime {
|
||||||
static size_t printStringTo(const std::string& s, Print& p) {
|
static size_t printStringTo(const std::string& s, Print& p) {
|
||||||
@ -61,8 +62,8 @@ TEST_CASE("Printable") {
|
|||||||
CHECK(doc.as<std::string>() == value);
|
CHECK(doc.as<std::string>() == value);
|
||||||
CHECK(printable.totalBytesWritten() == 7);
|
CHECK(printable.totalBytesWritten() == 7);
|
||||||
CHECK(doc.overflowed() == false);
|
CHECK(doc.overflowed() == false);
|
||||||
CHECK(doc.memoryUsage() == 8);
|
CHECK(doc.memoryUsage() == sizeofString(7));
|
||||||
CHECK(doc.as<JsonVariant>().memoryUsage() == 8);
|
CHECK(doc.as<JsonVariant>().memoryUsage() == sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Via Print::write(const char* size_t)") {
|
SECTION("Via Print::write(const char* size_t)") {
|
||||||
@ -71,8 +72,8 @@ TEST_CASE("Printable") {
|
|||||||
CHECK(doc.as<std::string>() == value);
|
CHECK(doc.as<std::string>() == value);
|
||||||
CHECK(printable.totalBytesWritten() == 7);
|
CHECK(printable.totalBytesWritten() == 7);
|
||||||
CHECK(doc.overflowed() == false);
|
CHECK(doc.overflowed() == false);
|
||||||
CHECK(doc.memoryUsage() == 8);
|
CHECK(doc.memoryUsage() == sizeofString(7));
|
||||||
CHECK(doc.as<JsonVariant>().memoryUsage() == 8);
|
CHECK(doc.as<JsonVariant>().memoryUsage() == sizeofString(7));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,6 +142,6 @@ TEST_CASE("Printable") {
|
|||||||
REQUIRE(doc.size() == 2);
|
REQUIRE(doc.size() == 2);
|
||||||
CHECK(doc[0] == "Hello World!");
|
CHECK(doc[0] == "Hello World!");
|
||||||
CHECK(doc[1] == "Hello World!");
|
CHECK(doc[1] == "Hello World!");
|
||||||
CHECK(doc.memoryUsage() == sizeofArray(2) + 13);
|
CHECK(doc.memoryUsage() == sizeofArray(2) + sizeofString(12));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("reject 0xc1") {
|
SECTION("reject 0xc1") {
|
||||||
@ -76,7 +76,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip true") {
|
SECTION("skip true") {
|
||||||
@ -85,7 +85,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip positive fixint") {
|
SECTION("skip positive fixint") {
|
||||||
@ -94,7 +94,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip negative fixint") {
|
SECTION("skip negative fixint") {
|
||||||
@ -103,7 +103,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip uint 8") {
|
SECTION("skip uint 8") {
|
||||||
@ -112,7 +112,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip int 8") {
|
SECTION("skip int 8") {
|
||||||
@ -121,7 +121,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip uint 16") {
|
SECTION("skip uint 16") {
|
||||||
@ -130,7 +130,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip int 16") {
|
SECTION("skip int 16") {
|
||||||
@ -139,7 +139,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip uint 32") {
|
SECTION("skip uint 32") {
|
||||||
@ -149,7 +149,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip int 32") {
|
SECTION("skip int 32") {
|
||||||
@ -159,7 +159,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip uint 64") {
|
SECTION("skip uint 64") {
|
||||||
@ -170,7 +170,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip int 64") {
|
SECTION("skip int 64") {
|
||||||
@ -181,7 +181,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip float 32") {
|
SECTION("skip float 32") {
|
||||||
@ -191,7 +191,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip float 64") {
|
SECTION("skip float 64") {
|
||||||
@ -202,7 +202,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip fixstr") {
|
SECTION("skip fixstr") {
|
||||||
@ -211,7 +211,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip str 8") {
|
SECTION("skip str 8") {
|
||||||
@ -220,7 +220,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip str 16") {
|
SECTION("skip str 16") {
|
||||||
@ -229,7 +229,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip str 32") {
|
SECTION("skip str 32") {
|
||||||
@ -239,7 +239,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip bin 8") {
|
SECTION("skip bin 8") {
|
||||||
@ -248,7 +248,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip bin 16") {
|
SECTION("skip bin 16") {
|
||||||
@ -257,7 +257,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip bin 32") {
|
SECTION("skip bin 32") {
|
||||||
@ -267,7 +267,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip fixarray") {
|
SECTION("skip fixarray") {
|
||||||
@ -276,7 +276,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip array 16") {
|
SECTION("skip array 16") {
|
||||||
@ -286,7 +286,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip array 32") {
|
SECTION("skip array 32") {
|
||||||
@ -299,7 +299,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip fixmap") {
|
SECTION("skip fixmap") {
|
||||||
@ -309,7 +309,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip map 16") {
|
SECTION("skip map 16") {
|
||||||
@ -321,7 +321,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip map 32") {
|
SECTION("skip map 32") {
|
||||||
@ -335,7 +335,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip fixext 1") {
|
SECTION("skip fixext 1") {
|
||||||
@ -347,7 +347,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip fixext 2") {
|
SECTION("skip fixext 2") {
|
||||||
@ -359,7 +359,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip fixext 4") {
|
SECTION("skip fixext 4") {
|
||||||
@ -371,7 +371,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip fixext 8") {
|
SECTION("skip fixext 8") {
|
||||||
@ -383,7 +383,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip fixext 16") {
|
SECTION("skip fixext 16") {
|
||||||
@ -397,7 +397,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip ext 8") {
|
SECTION("skip ext 8") {
|
||||||
@ -409,7 +409,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip ext 16") {
|
SECTION("skip ext 16") {
|
||||||
@ -421,7 +421,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip ext 32") {
|
SECTION("skip ext 32") {
|
||||||
@ -433,7 +433,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(1) + 8);
|
CHECK(doc.memoryUsage() == sizeofObject(1) + sizeofString(7));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,7 +454,8 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() ==
|
CHECK(doc.as<std::string>() ==
|
||||||
"{\"onlyarr\":[{\"measure\":2},{\"measure\":4}],\"include\":42}");
|
"{\"onlyarr\":[{\"measure\":2},{\"measure\":4}],\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofArray(2) + 2 * sizeofObject(2) + 24);
|
CHECK(doc.memoryUsage() ==
|
||||||
|
sizeofArray(2) + 2 * sizeofObject(2) + 3 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("include array 16") {
|
SECTION("include array 16") {
|
||||||
@ -469,7 +470,8 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() ==
|
CHECK(doc.as<std::string>() ==
|
||||||
"{\"onlyarr\":[{\"measure\":2},{\"measure\":4}],\"include\":42}");
|
"{\"onlyarr\":[{\"measure\":2},{\"measure\":4}],\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofArray(2) + 2 * sizeofObject(2) + 24);
|
CHECK(doc.memoryUsage() ==
|
||||||
|
sizeofArray(2) + 2 * sizeofObject(2) + 3 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("include array 32") {
|
SECTION("include array 32") {
|
||||||
@ -484,7 +486,8 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() ==
|
CHECK(doc.as<std::string>() ==
|
||||||
"{\"onlyarr\":[{\"measure\":2},{\"measure\":4}],\"include\":42}");
|
"{\"onlyarr\":[{\"measure\":2},{\"measure\":4}],\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofArray(2) + 2 * sizeofObject(2) + 24);
|
CHECK(doc.memoryUsage() ==
|
||||||
|
sizeofArray(2) + 2 * sizeofObject(2) + 3 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip null") {
|
SECTION("skip null") {
|
||||||
@ -493,7 +496,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip false") {
|
SECTION("skip false") {
|
||||||
@ -502,7 +505,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip true") {
|
SECTION("skip true") {
|
||||||
@ -511,7 +514,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip positive fixint") {
|
SECTION("skip positive fixint") {
|
||||||
@ -520,7 +523,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip negative fixint") {
|
SECTION("skip negative fixint") {
|
||||||
@ -529,7 +532,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip uint 8") {
|
SECTION("skip uint 8") {
|
||||||
@ -538,7 +541,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip uint 16") {
|
SECTION("skip uint 16") {
|
||||||
@ -547,7 +550,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip uint 32") {
|
SECTION("skip uint 32") {
|
||||||
@ -557,7 +560,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip uint 64") {
|
SECTION("skip uint 64") {
|
||||||
@ -568,7 +571,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip int 8") {
|
SECTION("skip int 8") {
|
||||||
@ -577,7 +580,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip int 16") {
|
SECTION("skip int 16") {
|
||||||
@ -586,7 +589,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip int 32") {
|
SECTION("skip int 32") {
|
||||||
@ -596,7 +599,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip int 64") {
|
SECTION("skip int 64") {
|
||||||
@ -607,7 +610,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip float 32") {
|
SECTION("skip float 32") {
|
||||||
@ -617,7 +620,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip float 64") {
|
SECTION("skip float 64") {
|
||||||
@ -628,7 +631,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip fixstr") {
|
SECTION("skip fixstr") {
|
||||||
@ -637,7 +640,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip str 8") {
|
SECTION("skip str 8") {
|
||||||
@ -659,7 +662,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
doc, "\x82\xA7onlyarr\xdb\x00\x00\x00\x05hello\xA7include\x2A",
|
doc, "\x82\xA7onlyarr\xdb\x00\x00\x00\x05hello\xA7include\x2A",
|
||||||
filterOpt);
|
filterOpt);
|
||||||
|
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip fixmap") {
|
SECTION("skip fixmap") {
|
||||||
@ -669,7 +672,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip map 16") {
|
SECTION("skip map 16") {
|
||||||
@ -681,7 +684,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip map 32") {
|
SECTION("skip map 32") {
|
||||||
@ -695,7 +698,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyarr\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -744,7 +747,8 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() ==
|
CHECK(doc.as<std::string>() ==
|
||||||
"{\"onlyobj\":{\"measure\":2},\"include\":42}");
|
"{\"onlyobj\":{\"measure\":2},\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + sizeofObject(1) + 24);
|
CHECK(doc.memoryUsage() ==
|
||||||
|
sizeofObject(2) + sizeofObject(1) + 3 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("include map 16") {
|
SECTION("include map 16") {
|
||||||
@ -757,7 +761,8 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() ==
|
CHECK(doc.as<std::string>() ==
|
||||||
"{\"onlyobj\":{\"measure\":2},\"include\":42}");
|
"{\"onlyobj\":{\"measure\":2},\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + sizeofObject(1) + 24);
|
CHECK(doc.memoryUsage() ==
|
||||||
|
sizeofObject(2) + sizeofObject(1) + 3 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("include map 32") {
|
SECTION("include map 32") {
|
||||||
@ -771,7 +776,8 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() ==
|
CHECK(doc.as<std::string>() ==
|
||||||
"{\"onlyobj\":{\"measure\":2},\"include\":42}");
|
"{\"onlyobj\":{\"measure\":2},\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + sizeofObject(1) + 24);
|
CHECK(doc.memoryUsage() ==
|
||||||
|
sizeofObject(2) + sizeofObject(1) + 3 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip null") {
|
SECTION("skip null") {
|
||||||
@ -780,7 +786,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip false") {
|
SECTION("skip false") {
|
||||||
@ -789,7 +795,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip true") {
|
SECTION("skip true") {
|
||||||
@ -798,7 +804,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip positive fixint") {
|
SECTION("skip positive fixint") {
|
||||||
@ -807,7 +813,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip negative fixint") {
|
SECTION("skip negative fixint") {
|
||||||
@ -816,7 +822,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip uint 8") {
|
SECTION("skip uint 8") {
|
||||||
@ -825,7 +831,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip uint 16") {
|
SECTION("skip uint 16") {
|
||||||
@ -834,7 +840,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip uint 32") {
|
SECTION("skip uint 32") {
|
||||||
@ -843,7 +849,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip uint 64") {
|
SECTION("skip uint 64") {
|
||||||
@ -854,7 +860,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip int 8") {
|
SECTION("skip int 8") {
|
||||||
@ -863,7 +869,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip int 16") {
|
SECTION("skip int 16") {
|
||||||
@ -872,7 +878,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip int 32") {
|
SECTION("skip int 32") {
|
||||||
@ -881,7 +887,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip int 64") {
|
SECTION("skip int 64") {
|
||||||
@ -892,7 +898,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip float 32") {
|
SECTION("skip float 32") {
|
||||||
@ -901,7 +907,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip float 64") {
|
SECTION("skip float 64") {
|
||||||
@ -912,7 +918,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip fixstr") {
|
SECTION("skip fixstr") {
|
||||||
@ -921,7 +927,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip str 8") {
|
SECTION("skip str 8") {
|
||||||
@ -943,7 +949,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
doc, "\x82\xA7onlyobj\xdb\x00\x00\x00\x05hello\xA7include\x2A",
|
doc, "\x82\xA7onlyobj\xdb\x00\x00\x00\x05hello\xA7include\x2A",
|
||||||
filterOpt);
|
filterOpt);
|
||||||
|
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip fixarray") {
|
SECTION("skip fixarray") {
|
||||||
@ -952,7 +958,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip array 16") {
|
SECTION("skip array 16") {
|
||||||
@ -963,7 +969,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("skip array 32") {
|
SECTION("skip array 32") {
|
||||||
@ -975,7 +981,7 @@ TEST_CASE("deserializeMsgPack() filter") {
|
|||||||
|
|
||||||
CHECK(error == DeserializationError::Ok);
|
CHECK(error == DeserializationError::Ok);
|
||||||
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
CHECK(doc.as<std::string>() == "{\"onlyobj\":null,\"include\":42}");
|
||||||
CHECK(doc.memoryUsage() == sizeofObject(2) + 16);
|
CHECK(doc.memoryUsage() == sizeofObject(2) + 2 * sizeofString(7));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user