Skip to content

Commit

Permalink
test(core): improve FieldsTrait coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
RiscadoA committed Sep 28, 2023
1 parent 9b9f2ef commit c325f95
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion core/tests/reflection/traits/fields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,18 @@ TEST_CASE("reflection::FieldsTrait")
ObjectType object{};
CHECK(field->name() == "foo");
CHECK(field->type().is<SimpleType>());
CHECK(fields.view(&object).get(*field) == &object.foo);

auto view = fields.view(&object);
CHECK(view.get(*field) == &object.foo);
CHECK(view.begin() != view.end());
CHECK(view.begin()->field == field);
CHECK(++view.begin() == view.end());

auto constView = fields.view(static_cast<const ObjectType*>(&object));
CHECK(constView.get(*field) == &object.foo);
CHECK(constView.begin() != constView.end());
CHECK(constView.begin()->field == field);
CHECK(++constView.begin() == constView.end());
}

SUBCASE("two fields")
Expand All @@ -66,5 +77,19 @@ TEST_CASE("reflection::FieldsTrait")
CHECK(barField->name() == "bar");
CHECK(barField->type().is<SimpleType>());
CHECK(fields.view(static_cast<const ObjectType*>(&object)).get(*barField) == &object.bar);

auto view = fields.view(&object);
CHECK(view.get(*fooField) == &object.foo);
CHECK(view.begin() != view.end());
CHECK(view.begin()->field == fooField);
CHECK((++view.begin())->field == barField);
CHECK(++(++view.begin()) == view.end());

auto constView = fields.view(static_cast<const ObjectType*>(&object));
CHECK(constView.get(*fooField) == &object.foo);
CHECK(constView.begin() != constView.end());
CHECK(constView.begin()->field == fooField);
CHECK((++constView.begin())->field == barField);
CHECK(++(++constView.begin()) == constView.end());
}
}

0 comments on commit c325f95

Please sign in to comment.