mirror of
https://github.com/ETLCPP/etl.git
synced 2026-11-09 22:59:47 +08:00
#781 etl::multi_span::iterator::operator *() fails if first span is empty
This commit is contained in:
parent
f1dd0d4490
commit
c400779905
@ -173,7 +173,19 @@ namespace etl
|
||||
{
|
||||
if (p_current != p_end)
|
||||
{
|
||||
p_value = p_current->begin();
|
||||
while ((p_current != p_end) && p_current->empty())
|
||||
{
|
||||
++p_current;
|
||||
}
|
||||
|
||||
if (p_current != p_end)
|
||||
{
|
||||
p_value = p_current->begin();
|
||||
}
|
||||
else
|
||||
{
|
||||
p_value = ETL_NULLPTR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -174,5 +174,36 @@ namespace
|
||||
++itr;
|
||||
CHECK_EQUAL(struct_data2[2].i, itr->i);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_multi_span_with_empty_spans)
|
||||
{
|
||||
std::vector<etl::span<Data>> span_list =
|
||||
{
|
||||
etl::span<Data>(),
|
||||
etl::span<Data>(struct_data1),
|
||||
etl::span<Data>(),
|
||||
etl::span<Data>(struct_data2),
|
||||
etl::span<Data>()
|
||||
};
|
||||
|
||||
etl::multi_span<Data> ms_data(etl::multi_span<Data>::span_list_type(std::begin(span_list), std::end(span_list)));
|
||||
|
||||
etl::multi_span<Data>::iterator itr = ms_data.begin();
|
||||
|
||||
CHECK_EQUAL(struct_data1[0].i, (*itr).i);
|
||||
++itr;
|
||||
CHECK_EQUAL(struct_data1[1].i, (*itr).i);
|
||||
++itr;
|
||||
CHECK_EQUAL(struct_data1[2].i, (*itr).i);
|
||||
++itr;
|
||||
CHECK_EQUAL(struct_data2[0].i, (*itr).i);
|
||||
++itr;
|
||||
CHECK_EQUAL(struct_data2[1].i, (*itr).i);
|
||||
++itr;
|
||||
CHECK_EQUAL(struct_data2[2].i, (*itr).i);
|
||||
++itr;
|
||||
CHECK_EQUAL(ETL_NULLPTR, itr.operator->());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user