qicosmos / iguana

universal serialization engine
Apache License 2.0
1.08k stars 224 forks source link

partial from json #261

Closed qicosmos closed 4 months ago

qicosmos commented 4 months ago
struct some_test_t {
  int id1;
  std::string name;
};
REFLECTION(some_test_t, id1, name);

struct dummy_nest_t {
  int id;
  some_test_t t;
};
REFLECTION(dummy_nest_t, id, t);

TEST_CASE("partial from json") {
  dummy_nest_t t{42, {43, "tom"}};
  std::string str;
  iguana::to_json(t, str);

  {
    dummy_nest_t t1;
    iguana::from_json<&dummy_nest_t::id>(t1, str);
    CHECK(t1.id == 42);
  }
  {
    dummy_nest_t t1;
    iguana::from_json<&dummy_nest_t::t>(t1, str);
    CHECK(t1.t.name == "tom");
  }

  {
    some_test_t t1;
    iguana::from_json<&some_test_t::name, dummy_nest_t>(t1, str);
    CHECK(t1.name == "tom");
  }
}
codecov-commenter commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 45.26%. Comparing base (fb6e6d5) to head (01951a9).

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #261 +/- ## ========================================== + Coverage 45.02% 45.26% +0.24% ========================================== Files 46 46 Lines 5628 5653 +25 ========================================== + Hits 2534 2559 +25 Misses 3094 3094 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.