-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
44 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
#define CATCH_CONFIG_MAIN | ||
|
||
#include <catch2/catch.hpp> | ||
#include <catch2/catch_all.hpp> | ||
|
||
TEST_CASE("1: test (pass)", "[multi-file:1]") { | ||
REQUIRE(1==1); | ||
} | ||
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
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 |
---|---|---|
@@ -1,28 +1,29 @@ | ||
#include <catch2/catch.hpp> | ||
#include "test_struct.hpp" | ||
#include <catch2/catch_all.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(); | ||
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"({ | ||
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)); | ||
rapidjson::Document json_c = | ||
serialize<rapidjson::Document>(deserialize<test>(json_v)); | ||
|
||
REQUIRE(str(json_v) == str(json_c)); | ||
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 |
---|---|---|
@@ -1,18 +1,13 @@ | ||
#include <catch2/catch.hpp> | ||
#include "test_struct.hpp" | ||
#include <catch2/catch_all.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>>); | ||
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 |
---|---|---|
@@ -1,25 +1,25 @@ | ||
#include <serdepp/serde.hpp> | ||
|
||
#pragma once | ||
|
||
#ifndef __CATCH_TEST_STRUCT_HPP__ | ||
#define __CATCH_TEST_STRUCT_HPP__ | ||
|
||
#include <serdepp/serde.hpp> | ||
|
||
struct nested { | ||
DERIVE_SERDE(nested, _SF_(str)) | ||
std::string str; | ||
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; | ||
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
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