Skip to content

Commit

Permalink
Using GTest for all other formats
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzicheng1987 committed Apr 22, 2024
1 parent 7aa7b0f commit e2f3cbb
Show file tree
Hide file tree
Showing 426 changed files with 882 additions and 3,278 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
*.cbor
*.json
*.fb
*.flexbuf
*.msgpack
*.toml
*.xml
Expand Down
16 changes: 13 additions & 3 deletions tests/bson/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
project(reflect-cpp-bson-tests)

file(GLOB_RECURSE SOURCES "*.cpp")
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "*.cpp")

add_executable(reflect-cpp-bson-tests ${SOURCES})
add_executable(
reflect-cpp-bson-tests
${SOURCES}
"${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/src/gtest_main.cc"
)

target_include_directories(reflect-cpp-bson-tests SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")
target_link_libraries(reflect-cpp-bson-tests PRIVATE reflectcpp)

target_link_libraries(
reflect-cpp-bson-tests
PRIVATE
reflectcpp
"${REFLECT_CPP_GTEST_LIB}"
)
8 changes: 2 additions & 6 deletions tests/bson/test_array.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "test_array.hpp"

#include <array>
#include <iostream>
#include <memory>
Expand All @@ -8,7 +6,7 @@
#include <string>

// Make sure things still compile when
// rfl.hpp is included after rfl/bson.hpp.
// rfl.hpp is included after rfl/cbor.hpp.
#include <rfl.hpp>

#include "write_and_read.hpp"
Expand All @@ -21,9 +19,7 @@ struct Person {
std::unique_ptr<std::array<Person, 3>> children = nullptr;
};

void test() {
std::cout << std::source_location::current().function_name() << std::endl;

TEST(bson, test_array) {
auto bart = Person{.first_name = "Bart"};

auto lisa = Person{.first_name = "Lisa"};
Expand Down
4 changes: 0 additions & 4 deletions tests/bson/test_array.hpp

This file was deleted.

6 changes: 1 addition & 5 deletions tests/bson/test_box.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "test_box.hpp"

#include <cassert>
#include <iostream>
#include <rfl.hpp>
Expand Down Expand Up @@ -29,9 +27,7 @@ struct DecisionTree {
rfl::Field<"leafOrNode", LeafOrNode> leaf_or_node;
};

void test() {
std::cout << std::source_location::current().function_name() << std::endl;

TEST(bson, test_box) {
auto leaf1 = DecisionTree::Leaf{.value = 3.0};

auto leaf2 = DecisionTree::Leaf{.value = 5.0};
Expand Down
4 changes: 0 additions & 4 deletions tests/bson/test_box.hpp

This file was deleted.

6 changes: 1 addition & 5 deletions tests/bson/test_custom_class1.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "test_custom_class1.hpp"

#include <cassert>
#include <iostream>
#include <rfl.hpp>
Expand Down Expand Up @@ -31,9 +29,7 @@ struct Person {
PersonImpl impl;
};

void test() {
std::cout << std::source_location::current().function_name() << std::endl;

TEST(bson, test_custom_class1) {
const auto bart = Person("Bart");

write_and_read(bart);
Expand Down
4 changes: 0 additions & 4 deletions tests/bson/test_custom_class1.hpp

This file was deleted.

6 changes: 1 addition & 5 deletions tests/bson/test_custom_class3.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "test_custom_class3.hpp"

#include <cassert>
#include <iostream>
#include <rfl.hpp>
Expand Down Expand Up @@ -56,9 +54,7 @@ struct Parser<ReaderType, WriterType, test_custom_class3::Person>

namespace test_custom_class3 {

void test() {
std::cout << std::source_location::current().function_name() << std::endl;

TEST(bson, test_custom_class3) {
const auto bart = Person("Bart", "Simpson", 10);

write_and_read(bart);
Expand Down
4 changes: 0 additions & 4 deletions tests/bson/test_custom_class3.hpp

This file was deleted.

6 changes: 1 addition & 5 deletions tests/bson/test_custom_class4.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "test_custom_class4.hpp"

#include <cassert>
#include <iostream>
#include <rfl.hpp>
Expand Down Expand Up @@ -57,9 +55,7 @@ struct Parser<ReaderType, WriterType, test_custom_class4::Person>

namespace test_custom_class4 {

void test() {
std::cout << std::source_location::current().function_name() << std::endl;

TEST(bson, test_custom_class4) {
const auto bart = test_custom_class4::Person(
"Bart", rfl::make_box<std::string>("Simpson"), 10);

Expand Down
4 changes: 0 additions & 4 deletions tests/bson/test_custom_class4.hpp

This file was deleted.

6 changes: 1 addition & 5 deletions tests/bson/test_default_values.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "test_default_values.hpp"

#include <cassert>
#include <iostream>
#include <rfl.hpp>
Expand All @@ -17,9 +15,7 @@ struct Person {
std::vector<Person> children;
};

void test() {
std::cout << std::source_location::current().function_name() << std::endl;

TEST(bson, test_default_values) {
const auto bart = Person{.first_name = "Bart"};
const auto lisa = Person{.first_name = "Lisa"};
const auto maggie = Person{.first_name = "Maggie"};
Expand Down
4 changes: 0 additions & 4 deletions tests/bson/test_default_values.hpp

This file was deleted.

6 changes: 1 addition & 5 deletions tests/bson/test_deque.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "test_deque.hpp"

#include <iostream>
#include <rfl.hpp>
#include <source_location>
Expand All @@ -16,9 +14,7 @@ struct Person {
std::unique_ptr<std::deque<Person>> children;
};

void test() {
std::cout << std::source_location::current().function_name() << std::endl;

TEST(bson, test_default_values) {
auto children = std::make_unique<std::deque<Person>>();
children->emplace_back(Person{.first_name = "Bart"});
children->emplace_back(Person{.first_name = "Lisa"});
Expand Down
4 changes: 0 additions & 4 deletions tests/bson/test_deque.hpp

This file was deleted.

6 changes: 1 addition & 5 deletions tests/bson/test_enum.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "test_enum.hpp"

#include <cassert>
#include <iostream>
#include <rfl.hpp>
Expand All @@ -18,9 +16,7 @@ struct Circle {
Color color;
};

void test() {
std::cout << std::source_location::current().function_name() << std::endl;

TEST(bson, test_enum) {
const auto circle = Circle{.radius = 2.0, .color = Color::green};

write_and_read(circle);
Expand Down
4 changes: 0 additions & 4 deletions tests/bson/test_enum.hpp

This file was deleted.

6 changes: 1 addition & 5 deletions tests/bson/test_field_variant.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "test_field_variant.hpp"

#include <cassert>
#include <iostream>
#include <rfl.hpp>
Expand Down Expand Up @@ -28,9 +26,7 @@ using Shapes = rfl::Variant<rfl::Field<"circle", Circle>,
rfl::Field<"rectangle", Rectangle>,
rfl::Field<"square", rfl::Box<Square>>>;

void test() {
std::cout << std::source_location::current().function_name() << std::endl;

TEST(bson, test_field_variant) {
const Shapes r =
rfl::make_field<"rectangle">(Rectangle{.height = 10, .width = 5});

Expand Down
4 changes: 0 additions & 4 deletions tests/bson/test_field_variant.hpp

This file was deleted.

5 changes: 1 addition & 4 deletions tests/bson/test_flag_enum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <string>
#include <vector>

#include "test_enum.hpp"
#include "write_and_read.hpp"

namespace test_flag_enum {
Expand All @@ -27,9 +26,7 @@ struct Circle {
Color color;
};

void test() {
std::cout << std::source_location::current().function_name() << std::endl;

TEST(bson, test_flag_enum) {
const auto circle =
Circle{.radius = 2.0, .color = Color::blue | Color::orange};

Expand Down
4 changes: 0 additions & 4 deletions tests/bson/test_flag_enum.hpp

This file was deleted.

5 changes: 1 addition & 4 deletions tests/bson/test_flag_enum_with_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <string>
#include <vector>

#include "test_enum.hpp"
#include "write_and_read.hpp"

namespace test_flag_enum_with_int {
Expand All @@ -27,9 +26,7 @@ struct Circle {
Color color;
};

void test() {
std::cout << std::source_location::current().function_name() << std::endl;

TEST(bson, test_flag_enum_with_int) {
const auto circle = Circle{.radius = 2.0, .color = static_cast<Color>(10000)};

write_and_read(circle);
Expand Down
4 changes: 0 additions & 4 deletions tests/bson/test_flag_enum_with_int.hpp

This file was deleted.

6 changes: 1 addition & 5 deletions tests/bson/test_flatten.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "test_flatten.hpp"

#include <cassert>
#include <iostream>
#include <rfl.hpp>
Expand All @@ -23,9 +21,7 @@ struct Employee {
rfl::Field<"salary", float> salary;
};

void test() {
std::cout << std::source_location::current().function_name() << std::endl;

TEST(bson, test_flatten) {
const auto employee = Employee{
.person = Person{.first_name = "Homer",
.last_name = rfl::make_box<std::string>("Simpson"),
Expand Down
4 changes: 0 additions & 4 deletions tests/bson/test_flatten.hpp

This file was deleted.

6 changes: 1 addition & 5 deletions tests/bson/test_flatten_anonymous.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "test_flatten_anonymous.hpp"

#include <cassert>
#include <iostream>
#include <rfl.hpp>
Expand All @@ -23,9 +21,7 @@ struct Employee {
float salary;
};

void test() {
std::cout << std::source_location::current().function_name() << std::endl;

TEST(bson, test_flatten_anonymous) {
const auto employee = Employee{
.person = Person{.first_name = "Homer",
.last_name = rfl::make_box<std::string>("Simpson"),
Expand Down
4 changes: 0 additions & 4 deletions tests/bson/test_flatten_anonymous.hpp

This file was deleted.

6 changes: 1 addition & 5 deletions tests/bson/test_forward_list.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "test_forward_list.hpp"

#include <iostream>
#include <rfl.hpp>
#include <source_location>
Expand All @@ -16,9 +14,7 @@ struct Person {
std::unique_ptr<std::forward_list<Person>> children;
};

void test() {
std::cout << std::source_location::current().function_name() << std::endl;

TEST(bson, test_forward_list) {
auto children = std::make_unique<std::forward_list<Person>>();
children->emplace_front(Person{.first_name = "Maggie"});
children->emplace_front(Person{.first_name = "Lisa"});
Expand Down
4 changes: 0 additions & 4 deletions tests/bson/test_forward_list.hpp

This file was deleted.

6 changes: 1 addition & 5 deletions tests/bson/test_literal.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "test_literal.hpp"

#include <cassert>
#include <iostream>
#include <rfl.hpp>
Expand All @@ -20,9 +18,7 @@ struct Person {
std::vector<Person> children;
};

void test() {
std::cout << std::source_location::current().function_name() << std::endl;

TEST(bson, test_literal) {
const auto bart = Person{.first_name = FirstName::make<"Bart">()};

write_and_read(bart);
Expand Down
4 changes: 0 additions & 4 deletions tests/bson/test_literal.hpp

This file was deleted.

Loading

0 comments on commit e2f3cbb

Please sign in to comment.