From 1689890b4128097a6d7a3a2e755042ceaecc1cdb Mon Sep 17 00:00:00 2001 From: qicosmos Date: Tue, 28 May 2024 08:43:05 +0800 Subject: [PATCH] add test --- test/test_pb.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/test_pb.cpp b/test/test_pb.cpp index 58b6c381..63804333 100644 --- a/test/test_pb.cpp +++ b/test/test_pb.cpp @@ -240,6 +240,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(t.get()); + auto p = *st; + std::cout << p.name << "\n"; + auto &r0 = t->get_field_value("name"); + CHECK(r0 == "test"); + auto &r = t->get_field_value("var"); + CHECK(r == 41); + auto &r1 = t->get_field_value("value"); + CHECK(r1.x == 2); + } { auto t = iguana::create_instance("pair_t"); t->set_field_value("x", 12);