Updated the flexbuffers tests

This commit is contained in:
Patrick Urbanke
2023-11-29 19:54:58 +01:00
parent 9f1ee3fe9b
commit 12528fe28b
34 changed files with 627 additions and 513 deletions
+16 -13
View File
@@ -2,24 +2,27 @@
#include <memory>
#include <rfl.hpp>
#include <rfl/flexbuf.hpp>
#include <source_location>
#include <string>
#include <unordered_map>
#include "write_and_read.hpp"
void test_string_unordered_map() {
std::cout << "test_string_unordered_map" << std::endl;
namespace test_string_unordered_map {
void test() {
std::cout << std::source_location::current().function_name() << std::endl;
using Map = std::unordered_map<std::string, std::unique_ptr<std::string>>;
Map homer;
homer.insert(
std::make_pair("firstName", std::make_unique<std::string>("Homer")));
homer.insert(
std::make_pair("lastName", std::make_unique<std::string>("Simpson")));
using Map = std::unordered_map<std::string, std::unique_ptr<std::string>>;
Map homer;
homer.insert(
std::make_pair("firstName", std::make_unique<std::string>("Homer")));
homer.insert(
std::make_pair("lastName", std::make_unique<std::string>("Simpson")));
// Unordered maps are unpredictable. We therefore only make sure that this
// compiles.
const auto json_string = rfl::flexbuf::write(homer);
const auto homer2 = rfl::flexbuf::read<Map>(json_string);
std::cout << "OK" << std::endl << std::endl;
// Unordered maps are unpredictable. We therefore only make sure that this
// compiles.
const auto json_string = rfl::flexbuf::write(homer);
const auto homer2 = rfl::flexbuf::read<Map>(json_string);
std::cout << "OK" << std::endl << std::endl;
}
} // namespace test_string_unordered_map