mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Fix bug in the void etl::unlink(first, last) for bidirectional links. (#1149)
* Reproduce bug in the `void etl::unlink(first, last)` for bidirectional links. - correct `test_unlink_range_bidirectional_link` unit test according to the documentation - now this test fails. - enhance `test_intrusive_list::test_splice_range_self` unit test to verify also `etl_previous` links after splicing lists - now unit test crashes. * Fix bug in the `void etl::unlink(first, last)` for bidirectional links. - `test_unlink_range_bidirectional_link` unit test now is green. - `test_intrusive_list::test_splice_range_self` is not crashing anymore and green.
This commit is contained in:
parent
400f438958
commit
4979c8a20b
@ -882,7 +882,6 @@ namespace etl
|
||||
if (first.etl_previous != ETL_NULLPTR)
|
||||
{
|
||||
first.etl_previous->etl_next = last.etl_next;
|
||||
last.clear();
|
||||
}
|
||||
|
||||
first.etl_previous = ETL_NULLPTR;
|
||||
|
||||
@ -1225,15 +1225,14 @@ namespace
|
||||
etl::link<BLink1>(data1, data0);
|
||||
etl::link<BLink1>(data0, nullptr);
|
||||
|
||||
// According to the documentation, `data1`/`data2` remain linked to each other.
|
||||
etl::unlink<BLink0>(data1, data2);
|
||||
data1.BLink0::clear();
|
||||
data2.BLink0::clear();
|
||||
|
||||
CHECK(data0.BLink0::etl_previous == nullptr);
|
||||
CHECK(data0.BLink0::etl_next == &data3);
|
||||
CHECK(data1.BLink0::etl_previous == nullptr);
|
||||
CHECK(data1.BLink0::etl_next == nullptr);
|
||||
CHECK(data2.BLink0::etl_previous == nullptr);
|
||||
CHECK(data1.BLink0::etl_next == &data2);
|
||||
CHECK(data2.BLink0::etl_previous == &data1);
|
||||
CHECK(data2.BLink0::etl_next == nullptr);
|
||||
CHECK(data3.BLink0::etl_previous == &data0);
|
||||
CHECK(data3.BLink0::etl_next == nullptr);
|
||||
|
||||
@ -1420,6 +1420,12 @@ namespace
|
||||
CHECK(are_equal);
|
||||
|
||||
CHECK_EQUAL(data0.size(), compare0.size());
|
||||
|
||||
// Double check that after splicing `etl_previous` is also correct - `.reverse()` easy way to do so.
|
||||
data0.reverse();
|
||||
compare0.reverse();
|
||||
are_equal = std::equal(data0.begin(), data0.end(), compare0.begin());
|
||||
CHECK(are_equal);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user