mirror of
https://github.com/ETLCPP/etl.git
synced 2026-11-09 22:59:47 +08:00
deque check index operator
This commit is contained in:
parent
27ce9364ec
commit
f61ea66d84
@ -791,6 +791,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
reference operator[](size_t index)
|
||||
{
|
||||
ETL_ASSERT_CHECK_INDEX_OPERATOR(index < current_size, ETL_ERROR(deque_out_of_bounds));
|
||||
|
||||
iterator result(_begin);
|
||||
result += static_cast<difference_type>(index);
|
||||
|
||||
@ -803,6 +805,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
const_reference operator[](size_t index) const
|
||||
{
|
||||
ETL_ASSERT_CHECK_INDEX_OPERATOR(index < current_size, ETL_ERROR(deque_out_of_bounds));
|
||||
|
||||
iterator result(_begin);
|
||||
result += static_cast<difference_type>(index);
|
||||
|
||||
@ -2196,7 +2200,8 @@ namespace etl
|
||||
|
||||
iterator item = _begin;
|
||||
|
||||
do {
|
||||
do
|
||||
{
|
||||
::new (&(*item)) T(*from);
|
||||
++item;
|
||||
++from;
|
||||
|
||||
@ -394,6 +394,14 @@ namespace
|
||||
CHECK_EQUAL(compare_data.at(5), data.at(5));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_at_out_of_bounds)
|
||||
{
|
||||
DataNDC data(initial_data.begin(), initial_data.end());
|
||||
|
||||
CHECK_THROW(data.at(data.size()), etl::deque_out_of_bounds);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_at_const)
|
||||
{
|
||||
@ -408,6 +416,14 @@ namespace
|
||||
CHECK_EQUAL(compare_data.at(5), data.at(5));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_at_const_out_of_bounds)
|
||||
{
|
||||
const DataNDC data(initial_data.begin(), initial_data.end());
|
||||
|
||||
CHECK_THROW(data.at(data.size()), etl::deque_out_of_bounds);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_index_operator)
|
||||
{
|
||||
@ -422,6 +438,14 @@ namespace
|
||||
CHECK_EQUAL(compare_data[5], data[5]);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_index_operator_out_of_bounds)
|
||||
{
|
||||
DataNDC data(initial_data.begin(), initial_data.end());
|
||||
|
||||
CHECK_THROW(data[data.size()], etl::deque_out_of_bounds);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_index_operator_const)
|
||||
{
|
||||
@ -436,6 +460,14 @@ namespace
|
||||
CHECK_EQUAL(compare_data[5], data[5]);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_index_operator_const_out_of_bounds)
|
||||
{
|
||||
const DataNDC data(initial_data.begin(), initial_data.end());
|
||||
|
||||
CHECK_THROW(data[data.size()], etl::deque_out_of_bounds);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
TEST(test_front)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user