Skip to content

Commit 0ee2966

Browse files
Added tests for more formats
1 parent 7d53623 commit 0ee2966

17 files changed

Lines changed: 337 additions & 64 deletions

tests/avro/test_box.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct DecisionTree {
2020

2121
using LeafOrNode = rfl::TaggedUnion<"type", Leaf, Node>;
2222

23-
rfl::Field<"leafOrNode", LeafOrNode> leaf_or_node;
23+
rfl::Rename<"leafOrNode", LeafOrNode> leaf_or_node;
2424
};
2525

2626
TEST(avro, test_box) {

tests/avro/test_custom_class4.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ struct Person {
2626
};
2727

2828
struct PersonImpl {
29-
rfl::Field<"firstName", std::string> first_name;
30-
rfl::Field<"lastName", rfl::Box<std::string>> last_name;
31-
rfl::Field<"age", int> age;
29+
rfl::Rename<"firstName", std::string> first_name;
30+
rfl::Rename<"lastName", rfl::Box<std::string>> last_name;
31+
rfl::Rename<"age", int> age;
3232

3333
static PersonImpl from_class(const Person& _p) noexcept {
3434
return PersonImpl{.first_name = _p.first_name(),

tests/avro/test_flatten.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
namespace test_flatten {
88

99
struct Person {
10-
rfl::Field<"firstName", std::string> first_name;
11-
rfl::Field<"lastName", rfl::Box<std::string>> last_name;
12-
rfl::Field<"age", int> age;
10+
rfl::Rename<"firstName", std::string> first_name;
11+
rfl::Rename<"lastName", rfl::Box<std::string>> last_name;
12+
rfl::Rename<"age", int> age;
1313
};
1414

1515
struct Employee {
1616
rfl::Flatten<Person> person;
17-
rfl::Field<"employer", rfl::Box<std::string>> employer;
18-
rfl::Field<"salary", float> salary;
17+
rfl::Rename<"employer", rfl::Box<std::string>> employer;
18+
rfl::Rename<"salary", float> salary;
1919
};
2020

2121
TEST(avro, test_flatten) {

tests/bson/test_box.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct DecisionTree {
2020

2121
using LeafOrNode = rfl::TaggedUnion<"type", Leaf, Node>;
2222

23-
rfl::Field<"leafOrNode", LeafOrNode> leaf_or_node;
23+
rfl::Rename<"leafOrNode", LeafOrNode> leaf_or_node;
2424
};
2525

2626
TEST(bson, test_box) {
@@ -36,6 +36,5 @@ TEST(bson, test_box) {
3636
const DecisionTree tree{.leaf_or_node = std::move(node)};
3737

3838
write_and_read(tree);
39-
4039
}
4140
} // namespace test_box

tests/bson/test_ref.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ struct DecisionTree {
2020

2121
using LeafOrNode = rfl::TaggedUnion<"type", Leaf, Node>;
2222

23-
rfl::Field<"leafOrNode", LeafOrNode> leaf_or_node;
23+
rfl::Rename<"leafOrNode", LeafOrNode> leaf_or_node;
2424
};
2525

26-
TEST(bson, test_ref) {
26+
TEST(bson, test_ref) {
2727
const auto leaf1 = DecisionTree::Leaf{.value = 3.0};
2828

2929
const auto leaf2 = DecisionTree::Leaf{.value = 5.0};
@@ -36,6 +36,5 @@ TEST(bson, test_ref) {
3636
const DecisionTree tree{.leaf_or_node = std::move(node)};
3737

3838
write_and_read(tree);
39-
4039
}
4140
} // namespace test_ref

tests/cbor/test_box.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct DecisionTree {
2020

2121
using LeafOrNode = rfl::TaggedUnion<"type", Leaf, Node>;
2222

23-
rfl::Field<"leafOrNode", LeafOrNode> leaf_or_node;
23+
rfl::Rename<"leafOrNode", LeafOrNode> leaf_or_node;
2424
};
2525

2626
TEST(cbor, test_box) {
@@ -36,6 +36,5 @@ TEST(cbor, test_box) {
3636
const DecisionTree tree{.leaf_or_node = std::move(node)};
3737

3838
write_and_read(tree);
39-
4039
}
4140
} // namespace test_box

tests/cbor/test_ref.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ struct DecisionTree {
2020

2121
using LeafOrNode = rfl::TaggedUnion<"type", Leaf, Node>;
2222

23-
rfl::Field<"leafOrNode", LeafOrNode> leaf_or_node;
23+
rfl::Rename<"leafOrNode", LeafOrNode> leaf_or_node;
2424
};
2525

26-
TEST(cbor, test_ref) {
26+
TEST(cbor, test_ref) {
2727
const auto leaf1 = DecisionTree::Leaf{.value = 3.0};
2828

2929
const auto leaf2 = DecisionTree::Leaf{.value = 5.0};
@@ -36,6 +36,5 @@ TEST(cbor, test_ref) {
3636
const DecisionTree tree{.leaf_or_node = std::move(node)};
3737

3838
write_and_read(tree);
39-
4039
}
4140
} // namespace test_ref

tests/flexbuffers/test_box.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct DecisionTree {
2020

2121
using LeafOrNode = rfl::TaggedUnion<"type", Leaf, Node>;
2222

23-
rfl::Field<"leafOrNode", LeafOrNode> leaf_or_node;
23+
rfl::Rename<"leafOrNode", LeafOrNode> leaf_or_node;
2424
};
2525

2626
TEST(flexbuf, test_box) {
@@ -36,6 +36,5 @@ TEST(flexbuf, test_box) {
3636
const DecisionTree tree{.leaf_or_node = std::move(node)};
3737

3838
write_and_read(tree);
39-
4039
}
4140
} // namespace test_box

tests/flexbuffers/test_ref.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ struct DecisionTree {
2020

2121
using LeafOrNode = rfl::TaggedUnion<"type", Leaf, Node>;
2222

23-
rfl::Field<"leafOrNode", LeafOrNode> leaf_or_node;
23+
rfl::Rename<"leafOrNode", LeafOrNode> leaf_or_node;
2424
};
2525

26-
TEST(flexbuf, test_ref) {
26+
TEST(flexbuf, test_ref) {
2727
const auto leaf1 = DecisionTree::Leaf{.value = 3.0};
2828

2929
const auto leaf2 = DecisionTree::Leaf{.value = 5.0};
@@ -36,6 +36,5 @@ TEST(flexbuf, test_ref) {
3636
const DecisionTree tree{.leaf_or_node = std::move(node)};
3737

3838
write_and_read(tree);
39-
4039
}
4140
} // namespace test_ref

tests/modules/CMakeLists.txt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,59 @@ cmake_minimum_required(VERSION 3.28)
22

33
add_executable(reflect-cpp-modules-tests)
44

5+
if(REFLECTCPP_JSON)
6+
target_compile_definitions(reflect-cpp-modules-tests PUBLIC REFLECTCPP_JSON)
7+
endif()
8+
9+
if(REFLECTCPP_AVRO)
10+
target_compile_definitions(reflect-cpp-modules-tests PUBLIC REFLECTCPP_AVRO)
11+
endif()
12+
13+
if(REFLECTCPP_BSON)
14+
target_compile_definitions(reflect-cpp-modules-tests PUBLIC REFLECTCPP_BSON)
15+
endif()
16+
17+
if(REFLECTCPP_CAPNPROTO)
18+
target_compile_definitions(reflect-cpp-modules-tests PUBLIC REFLECTCPP_CAPNPROTO)
19+
endif()
20+
21+
if(REFLECTCPP_CBOR)
22+
target_compile_definitions(reflect-cpp-modules-tests PUBLIC REFLECTCPP_CBOR)
23+
endif()
24+
25+
if(REFLECTCPP_CSV)
26+
target_compile_definitions(reflect-cpp-modules-tests PUBLIC REFLECTCPP_CSV)
27+
endif()
28+
29+
if(REFLECTCPP_FLEXBUFFERS)
30+
target_compile_definitions(reflect-cpp-modules-tests PUBLIC REFLECTCPP_FLEXBUFFERS)
31+
endif()
32+
33+
if(REFLECTCPP_MSGPACK)
34+
target_compile_definitions(reflect-cpp-modules-tests PUBLIC REFLECTCPP_MSGPACK)
35+
endif()
36+
37+
if(REFLECTCPP_PARQUET)
38+
target_compile_definitions(reflect-cpp-modules-tests PUBLIC REFLECTCPP_PARQUET)
39+
endif()
40+
41+
if(REFLECTCPP_TOML)
42+
target_compile_definitions(reflect-cpp-modules-tests PUBLIC REFLECTCPP_TOML)
43+
endif()
44+
45+
if(REFLECTCPP_UBJSON)
46+
target_compile_definitions(reflect-cpp-modules-tests PUBLIC REFLECTCPP_UBJSON)
47+
endif()
48+
49+
if(REFLECTCPP_XML)
50+
target_compile_definitions(reflect-cpp-modules-tests PUBLIC REFLECTCPP_XML)
51+
endif()
52+
53+
if(REFLECTCPP_YAML)
54+
target_compile_definitions(reflect-cpp-modules-tests PUBLIC REFLECTCPP_YAML)
55+
endif()
56+
57+
558
target_include_directories(reflect-cpp-modules-tests PUBLIC
659
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
760
$<INSTALL_INTERFACE:include>

0 commit comments

Comments
 (0)