Skip to content

Commit

Permalink
simplify obtaining mutable type from collection
Browse files Browse the repository at this point in the history
  • Loading branch information
m-fila committed Dec 19, 2024
1 parent a013f1b commit da8b0ba
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/unittests/std_interoperability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,23 +749,23 @@ TEST_CASE("Collection iterators", "[collection][container][iterator][std]") {
// *r = o
// iterator
DOCUMENTED_STATIC_FAILURE(traits::has_dereference_assignment_v<iterator, CollectionType::value_type>);
STATIC_REQUIRE(traits::has_dereference_assignment_v<iterator, CollectionType::value_type::mutable_type>);
STATIC_REQUIRE(traits::has_dereference_assignment_v<iterator, CollectionType::mutable_type>);
{
auto coll = CollectionType{};
auto item = coll.create(13ull, 0., 0., 0., 0.);
REQUIRE(coll.begin()->cellID() == 13ull);
auto new_item = CollectionType::value_type::mutable_type{42ull, 0., 0., 0., 0.};
auto new_item = CollectionType::mutable_type{42ull, 0., 0., 0., 0.};
*coll.begin() = new_item;
DOCUMENTED_FAILURE(coll.begin()->cellID() == 42ull);
}
// const_iterator
STATIC_REQUIRE(traits::has_dereference_assignment_v<const_iterator, CollectionType::value_type>);
STATIC_REQUIRE(traits::has_dereference_assignment_v<const_iterator, CollectionType::value_type::mutable_type>);
STATIC_REQUIRE(traits::has_dereference_assignment_v<const_iterator, CollectionType::mutable_type>);
{
auto coll = CollectionType{};
auto item = coll.create(13ull, 0., 0., 0., 0.);
REQUIRE(coll.cbegin()->cellID() == 13ull);
auto new_item = CollectionType::value_type::mutable_type{42ull, 0., 0., 0., 0.};
auto new_item = CollectionType::mutable_type{42ull, 0., 0., 0., 0.};
*coll.cbegin() = new_item;
DOCUMENTED_FAILURE(coll.cbegin()->cellID() == 42ull);
new_item.cellID(44ull);
Expand Down Expand Up @@ -793,13 +793,13 @@ TEST_CASE("Collection iterators", "[collection][container][iterator][std]") {
// iterator
DOCUMENTED_STATIC_FAILURE(traits::has_dereference_assignment_increment_v<iterator, CollectionType::value_type>);
DOCUMENTED_STATIC_FAILURE(
traits::has_dereference_assignment_increment_v<iterator, CollectionType::value_type::mutable_type>);
traits::has_dereference_assignment_increment_v<iterator, CollectionType::mutable_type>);
// TODO add runtime check for assignment validity like in '*r = o' case
// const_iterator
DOCUMENTED_STATIC_FAILURE(
traits::has_dereference_assignment_increment_v<const_iterator, CollectionType::value_type>);
DOCUMENTED_STATIC_FAILURE(
traits::has_dereference_assignment_increment_v<const_iterator, CollectionType::value_type::mutable_type>);
traits::has_dereference_assignment_increment_v<const_iterator, CollectionType::mutable_type>);
// TODO add runtime check for assignment validity like in '*r = o' case

// iterator_category - not strictly necessary but advised
Expand Down Expand Up @@ -852,7 +852,7 @@ TEST_CASE("Collection and std iterator adaptors", "[collection][container][adapt
// insert immutable to not-SubsetCollection
REQUIRE_THROWS_AS(it = CollectionType::value_type{}, std::invalid_argument);
// insert mutable (implicit cast to immutable) to not-SubsetCollection
REQUIRE_THROWS_AS(it = CollectionType::value_type::mutable_type{}, std::invalid_argument);
REQUIRE_THROWS_AS(it = CollectionType::mutable_type{}, std::invalid_argument);
auto subColl = CollectionType{};
subColl.setSubsetCollection(true);
auto subIt = std::back_inserter(subColl);
Expand Down

0 comments on commit da8b0ba

Please sign in to comment.