-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml-cpp: 0.6.3 -> 0.7.0, rapidjson Map bugfix, and unittest
- Loading branch information
Showing
14 changed files
with
220 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#define CATCH_CONFIG_MAIN | ||
|
||
#include <catch2/catch.hpp> | ||
|
||
TEST_CASE("1: test (pass)", "[multi-file:1]") { | ||
REQUIRE(1==1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
#include <catch2/catch.hpp> | ||
#include "test_struct.hpp" | ||
#include <serdepp/adaptor/nlohmann_json.hpp> | ||
|
||
|
||
nlohmann::json json_v = R"({ | ||
"str" : "hello", | ||
"i": 10, | ||
"vec": [ "one", "two", "three"], | ||
"sm": { "one" : "tone", "two" : "ttwo"}, | ||
"opt": "hello", | ||
"sub" : { "str": "hello" } | ||
})"_json; | ||
|
||
using namespace serde; | ||
|
||
TEST_CASE("2: nlohmann json struct (pass)", "[multi-file:2]") { | ||
REQUIRE(json_v.dump() == serialize<nlohmann::json>(deserialize<test>(json_v)).dump()); | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <catch2/catch.hpp> | ||
#include "test_struct.hpp" | ||
#include <serdepp/adaptor/rapidjson.hpp> | ||
|
||
std::string str(rapidjson::Document& doc) { | ||
using namespace rapidjson; | ||
StringBuffer buffer; | ||
Writer<StringBuffer> writer(buffer); | ||
doc.Accept(writer); | ||
return buffer.GetString(); | ||
}; | ||
|
||
using namespace serde; | ||
|
||
TEST_CASE("5: toml11 struct (pass)", "[multi-file:5]") { | ||
rapidjson::Document json_v; | ||
json_v.Parse(R"({ | ||
"str" : "hello", | ||
"i": 10, | ||
"vec": [ "one", "two", "three"], | ||
"opt": "hello", | ||
"sm": { "one" : "tone", "two" : "ttwo"}, | ||
"sub" : { "str": "hello" } | ||
})"); | ||
rapidjson::Document json_c = serialize<rapidjson::Document>(deserialize<test>(json_v)); | ||
|
||
REQUIRE(str(json_v) == str(json_c)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <catch2/catch.hpp> | ||
#include "test_struct.hpp" | ||
#include <serdepp/adaptor/reflection.hpp> | ||
|
||
using namespace serde; | ||
|
||
TEST_CASE("3: reflection struct (pass)", "[multi-file:3]") { | ||
REQUIRE(std::is_same_v<to_tuple_t<test>, | ||
std::tuple<std::string, | ||
int, | ||
std::vector<std::string>, | ||
std::optional<std::string>, | ||
std::optional<std::string>, | ||
std::map<std::string, std::string>, | ||
nested>>); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <serdepp/serde.hpp> | ||
|
||
#pragma once | ||
|
||
#ifndef __CATCH_TEST_STRUCT_HPP__ | ||
#define __CATCH_TEST_STRUCT_HPP__ | ||
|
||
struct nested { | ||
DERIVE_SERDE(nested, _SF_(str)) | ||
std::string str; | ||
}; | ||
|
||
struct test { | ||
DERIVE_SERDE(test, _SF_(str)_SF_(i)_SF_(vec)_SF_(opt)_SF_(none_opt)_SF_(sm)_SF_(sub)) | ||
std::string str; | ||
int i; | ||
std::vector<std::string> vec; | ||
std::optional<std::string> none_opt; | ||
std::optional<std::string> opt; | ||
std::map<std::string, std::string> sm; | ||
nested sub; | ||
}; | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <catch2/catch.hpp> | ||
#include "test_struct.hpp" | ||
#include <serdepp/adaptor/toml11.hpp> | ||
|
||
using namespace serde; | ||
|
||
using namespace toml::literals; | ||
|
||
toml::value toml_vl = R"( | ||
str = "hello" | ||
i = 10 | ||
vec = [ "one", "two", "three" ] | ||
opt = "hello" | ||
[sm] | ||
one = "tone" | ||
two = "ttwo" | ||
[sub] | ||
str = "hello" | ||
)"_toml; | ||
|
||
TEST_CASE("4: toml11 struct (pass)", "[multi-file:4]") { | ||
REQUIRE(toml_vl == serialize<toml::value>(deserialize<test>(toml_vl))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <catch2/catch.hpp> | ||
#include "test_struct.hpp" | ||
#include <serdepp/adaptor/yaml-cpp.hpp> | ||
|
||
|
||
YAML::Node yaml_v = YAML::Load(R"( | ||
str: hello | ||
i: 10 | ||
vec: | ||
- one | ||
- two | ||
- three | ||
opt: hello | ||
sm: | ||
one: tone | ||
two: ttwo | ||
sub: | ||
str: hello | ||
)"); | ||
|
||
using namespace serde; | ||
|
||
TEST_CASE("5: yaml-cpp struct (pass)", "[multi-file:5]") { | ||
std::ostringstream origin; | ||
origin << yaml_v; | ||
std::ostringstream convert; | ||
convert << serialize<YAML::Node>(deserialize<test>(yaml_v)); | ||
|
||
REQUIRE(origin.str() == convert.str()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[Catch2] | ||
version = "2.9.1" | ||
description = "modern, C++-native, header-only, test framework for unit-tests" | ||
module = "Catch2::Catch2" | ||
url="https://github.com/catchorg/Catch2/archive/v2.9.1.tar.gz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[yaml-cpp] | ||
version="0.7.0" #(require) | ||
type="lib" #lib(default) | bin | cmake | ||
description="" #(require) | ||
module="yaml-cpp" #(require) if none_module=true -> no require | ||
flags="-DYAML_CPP_BUILD_TESTS=OFF" | ||
url="https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.7.0.zip" #(require) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Cppkg Base Dependency Downloader | ||
cmake_minimum_required(VERSION 3.6) | ||
project(yaml-cpp-0.6.3-install) | ||
|
||
set(CPPM_VERSION ${CPPM_VERSION}) | ||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppm_loader.cmake) | ||
download_package(yaml-cpp 0.6.3 URL https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.6.3.tar.gz TYPE lib CMAKE_ARGS ${CMAKE_ARGS} -DYAML_CPP_BUILD_TESTS=OFF) | ||
|