Skip to content

Commit

Permalink
Beautified the inheritance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzicheng1987 committed Apr 18, 2024
1 parent 3f4def6 commit 4d2116a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/json/test_inheritance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ void test() {

const auto name = get<0>(rfl::fields<T>()).name();
if (name == "x") {
std::cout << "OK" << std::endl;
std::cout << "OK" << std::endl << std::endl;
} else {
std::cout << "FAIL\n"
<< "Expected member name 'x', got '" << name << "'" << std::endl;
}
}

} // namespace test_inheritance
} // namespace test_inheritance
8 changes: 6 additions & 2 deletions tests/json/test_inheritance2.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <cassert>
#include <iostream>
#include <rfl.hpp>
#include <source_location>

#include "rfl/internal/num_fields.hpp"

Expand All @@ -27,9 +28,12 @@ struct EmptyDerived1 : EmptyBase1, BaseX {};
struct EmptyDerived2 : EmptyBase1, EmptyBase2, BaseX {};

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

Derived1 derived1;
const auto derived1_view = rfl::to_view(derived1);
static_assert(derived1_view.size() == 2);

Derived2 derived2;
const auto derived2_view = rfl::to_view(derived2);
static_assert(derived2_view.size() == 3);
Expand All @@ -46,7 +50,7 @@ void test() {
auto empty_derived2_view = rfl::to_view(empty_derived2);
static_assert(empty_derived0_view.size() == 2);

std::cout << "OK\n";
std::cout << "OK" << std::endl << std::endl;
}

} // namespace test_inheritance
} // namespace test_inheritance2

0 comments on commit 4d2116a

Please sign in to comment.