mirror of
https://github.com/ETLCPP/etl.git
synced 2026-05-01 11:29:09 +08:00
Modified unit tests to use CHECK_THROW
This commit is contained in:
parent
585b494aa1
commit
4e2bfb2740
@ -153,18 +153,7 @@ namespace
|
||||
CHECK_EQUAL(data.at(i), testData.at(i));
|
||||
}
|
||||
|
||||
bool gotException = false;
|
||||
|
||||
try
|
||||
{
|
||||
data.at(data.size());
|
||||
}
|
||||
catch (etl::array_out_of_range_exception)
|
||||
{
|
||||
gotException = true;
|
||||
}
|
||||
|
||||
CHECK(gotException);
|
||||
CHECK_THROW(data.at(data.size()), etl::array_out_of_range_exception);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -175,18 +164,7 @@ namespace
|
||||
CHECK_EQUAL(data.at(i), testData.at(i));
|
||||
}
|
||||
|
||||
bool gotException = false;
|
||||
|
||||
try
|
||||
{
|
||||
data.at(data.size());
|
||||
}
|
||||
catch (etl::array_out_of_range_exception)
|
||||
{
|
||||
gotException = true;
|
||||
}
|
||||
|
||||
CHECK(gotException);
|
||||
CHECK_THROW(data.at(data.size()), etl::array_out_of_range_exception);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -129,25 +129,12 @@ namespace
|
||||
{
|
||||
etl::queue<int, 4> queue;
|
||||
|
||||
bool gotException = false;
|
||||
|
||||
try
|
||||
for (size_t i = 0; i < queue.capacity(); ++i)
|
||||
{
|
||||
for (size_t i = 0; i < queue.capacity() + 1; ++i)
|
||||
{
|
||||
queue.push(1);
|
||||
}
|
||||
}
|
||||
catch (etl::queue_full_exception&)
|
||||
{
|
||||
gotException = true;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
CHECK(false);
|
||||
queue.push(1);
|
||||
}
|
||||
|
||||
CHECK(gotException);
|
||||
CHECK_THROW(queue.push(1), etl::queue_full_exception);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -203,22 +190,7 @@ namespace
|
||||
{
|
||||
etl::queue<int, 4> queue;
|
||||
|
||||
bool gotException = false;
|
||||
|
||||
try
|
||||
{
|
||||
queue.front();
|
||||
}
|
||||
catch (etl::queue_empty_exception&)
|
||||
{
|
||||
gotException = true;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
CHECK(false);
|
||||
}
|
||||
|
||||
CHECK(gotException);
|
||||
CHECK_THROW(queue.front(), etl::queue_empty_exception);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -257,22 +229,7 @@ namespace
|
||||
{
|
||||
etl::queue<int, 4> queue;
|
||||
|
||||
bool gotException = false;
|
||||
|
||||
try
|
||||
{
|
||||
queue.back();
|
||||
}
|
||||
catch (etl::queue_empty_exception&)
|
||||
{
|
||||
gotException = true;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
CHECK(false);
|
||||
}
|
||||
|
||||
CHECK(gotException);
|
||||
CHECK_THROW(queue.back(), etl::queue_empty_exception);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -129,25 +129,12 @@ namespace
|
||||
{
|
||||
etl::stack<int, 4> stack;
|
||||
|
||||
bool gotException = false;
|
||||
|
||||
try
|
||||
for (size_t i = 0; i < stack.capacity(); ++i)
|
||||
{
|
||||
for (size_t i = 0; i < stack.capacity() + 1; ++i)
|
||||
{
|
||||
stack.push(1);
|
||||
}
|
||||
}
|
||||
catch (etl::stack_full_exception&)
|
||||
{
|
||||
gotException = true;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
CHECK(false);
|
||||
stack.push(1);
|
||||
}
|
||||
|
||||
CHECK(gotException);
|
||||
CHECK_THROW(stack.push(1), etl::stack_full_exception);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -203,22 +190,7 @@ namespace
|
||||
{
|
||||
etl::stack<int, 4> stack;
|
||||
|
||||
bool gotException = false;
|
||||
|
||||
try
|
||||
{
|
||||
stack.top();
|
||||
}
|
||||
catch (etl::stack_empty_exception&)
|
||||
{
|
||||
gotException = true;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
CHECK(false);
|
||||
}
|
||||
|
||||
CHECK(gotException);
|
||||
CHECK_THROW(stack.top(), etl::stack_empty_exception);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user