Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos committed May 28, 2024
1 parent 6738b98 commit 414ea78
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/test_pb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,22 @@ struct numer_st BASE(numer_st) {
REFLECTION(numer_st, a, b, c);

TEST_CASE("test reflection") {
{
auto t = iguana::create_instance("nest1");
my_struct mt{2, true, {42}};
t->set_field_value("value", mt);
t->set_field_value("name", std::string("test"));
t->set_field_value("var", 41);
nest1 *st = dynamic_cast<nest1 *>(t.get());
auto p = *st;
std::cout << p.name << "\n";
auto &r0 = t->get_field_value<std::string>("name");
CHECK(r0 == "test");
auto &r = t->get_field_value<int>("var");
CHECK(r == 41);
auto &r1 = t->get_field_value<my_struct>("value");
CHECK(r1.x == 2);
}
{
auto t = iguana::create_instance("pair_t");
t->set_field_value("x", 12);
Expand Down

0 comments on commit 414ea78

Please sign in to comment.