mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
migrate from dynamic::Value to dv::value & total erase namespace 'dynamic'
This commit is contained in:
parent
d3ba4b2e3e
commit
34d2e6d400
69 changed files with 1247 additions and 2248 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "data/dynamic.hpp"
|
||||
#include "util/Buffer.hpp"
|
||||
#include "coders/binary_json.hpp"
|
||||
|
||||
TEST(BJSON, EncodeDecode) {
|
||||
|
|
@ -8,41 +8,7 @@ TEST(BJSON, EncodeDecode) {
|
|||
const int bytesSize = 5000;
|
||||
const int year = 2019;
|
||||
const float score = 3.141592;
|
||||
dynamic::ByteBuffer srcBytes(bytesSize);
|
||||
for (int i = 0; i < bytesSize; i ++) {
|
||||
srcBytes[i] = rand();
|
||||
}
|
||||
|
||||
std::vector<ubyte> bjsonBytes;
|
||||
{
|
||||
dynamic::Map map;
|
||||
map.put("name", name);
|
||||
map.put("year", year);
|
||||
map.put("score", score);
|
||||
map.put("data", &srcBytes);
|
||||
|
||||
bjsonBytes = json::to_binary(&map, false);
|
||||
}
|
||||
{
|
||||
auto map = json::from_binary(bjsonBytes.data(), bjsonBytes.size());
|
||||
EXPECT_EQ(map->get<std::string>("name"), name);
|
||||
EXPECT_EQ(map->get<integer_t>("year"), year);
|
||||
EXPECT_FLOAT_EQ(map->get<number_t>("score"), score);
|
||||
auto bytesptr = map->bytes("data");
|
||||
const auto& bytes = *bytesptr;
|
||||
EXPECT_EQ(bytes.size(), bytesSize);
|
||||
for (int i = 0; i < bytesSize; i++) {
|
||||
EXPECT_EQ(bytes[i], srcBytes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(BJSON, EncodeDecodeDV) {
|
||||
const std::string name = "JSON-encoder";
|
||||
const int bytesSize = 5000;
|
||||
const int year = 2019;
|
||||
const float score = 3.141592;
|
||||
dynamic::ByteBuffer srcBytes(bytesSize);
|
||||
dv::objects::Bytes srcBytes(bytesSize);
|
||||
for (int i = 0; i < bytesSize; i ++) {
|
||||
srcBytes[i] = rand();
|
||||
}
|
||||
|
|
@ -55,10 +21,10 @@ TEST(BJSON, EncodeDecodeDV) {
|
|||
object["score"] = score;
|
||||
object["data"] = srcBytes;
|
||||
|
||||
bjsonBytes = json::to_binaryDV(object, false);
|
||||
bjsonBytes = json::to_binary(object, false);
|
||||
}
|
||||
{
|
||||
auto object = json::from_binaryDV(bjsonBytes.data(), bjsonBytes.size());
|
||||
auto object = json::from_binary(bjsonBytes.data(), bjsonBytes.size());
|
||||
|
||||
EXPECT_EQ(object["name"].asString(), name);
|
||||
EXPECT_EQ(object["year"].asInteger(), year);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue