Skip to content

Commit

Permalink
Fix #709 in intrusive_list operator-> (#721)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chiraffollo committed Jul 1, 2023
1 parent 96092d8 commit 7f990d7
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/etl/intrusive_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ namespace etl

pointer operator ->() const
{
return *static_cast<pointer>(p_value);
return static_cast<pointer>(p_value);
}

friend bool operator == (const iterator& lhs, const iterator& rhs)
Expand Down
30 changes: 30 additions & 0 deletions test/test_intrusive_forward_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,21 @@ namespace
CHECK(are_equal);
}

//*************************************************************************
TEST_FIXTURE(SetupFixture, test_iterator_arrow_operator)
{
ItemNDCNode item1("1");
ItemNDCNode item2("2");
DataNDC0 data;
data.push_front(item2);
data.push_front(item1);

auto iter = data.begin();
CHECK(*(iter.operator->()) == item1);
++iter;
CHECK(*(iter.operator->()) == item2);
}

//*************************************************************************
TEST_FIXTURE(SetupFixture, test_const_iterator)
{
Expand All @@ -219,6 +234,21 @@ namespace
CHECK(are_equal);
}

//*************************************************************************
TEST_FIXTURE(SetupFixture, test_const_iterator_arrow_operator)
{
ItemNDCNode item1("1");
ItemNDCNode item2("2");
DataNDC0 data;
data.push_front(item2);
data.push_front(item1);

auto iter = data.cbegin();
CHECK(*(iter.operator->()) == item1);
++iter;
CHECK(*(iter.operator->()) == item2);
}

//*************************************************************************
TEST_FIXTURE(SetupFixture, test_clear)
{
Expand Down
30 changes: 30 additions & 0 deletions test/test_intrusive_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,21 @@ namespace
CHECK(are_equal);
}

//*************************************************************************
TEST_FIXTURE(SetupFixture, test_iterator_arrow_operator)
{
ItemNDCNode item1("1");
ItemNDCNode item2("2");
DataNDC0 data;
data.push_back(item1);
data.push_back(item2);

auto iter = data.begin();
CHECK(*(iter.operator->()) == item1);
++iter;
CHECK(*(iter.operator->()) == item2);
}

//*************************************************************************
TEST_FIXTURE(SetupFixture, test_const_iterator)
{
Expand All @@ -234,6 +249,21 @@ namespace
CHECK(are_equal);
}

//*************************************************************************
TEST_FIXTURE(SetupFixture, test_const_iterator_arrow_operator)
{
ItemNDCNode item1("1");
ItemNDCNode item2("2");
DataNDC0 data;
data.push_back(item1);
data.push_back(item2);

auto iter = data.cbegin();
CHECK(*(iter.operator->()) == item1);
++iter;
CHECK(*(iter.operator->()) == item2);
}

//*************************************************************************
TEST_FIXTURE(SetupFixture, test_clear)
{
Expand Down

0 comments on commit 7f990d7

Please sign in to comment.