mirror of
https://github.com/ETLCPP/etl.git
synced 2026-11-09 22:59:47 +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));
|
CHECK_EQUAL(data.at(i), testData.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gotException = false;
|
CHECK_THROW(data.at(data.size()), etl::array_out_of_range_exception);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
data.at(data.size());
|
|
||||||
}
|
|
||||||
catch (etl::array_out_of_range_exception)
|
|
||||||
{
|
|
||||||
gotException = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
CHECK(gotException);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
@ -175,18 +164,7 @@ namespace
|
|||||||
CHECK_EQUAL(data.at(i), testData.at(i));
|
CHECK_EQUAL(data.at(i), testData.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gotException = false;
|
CHECK_THROW(data.at(data.size()), etl::array_out_of_range_exception);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
data.at(data.size());
|
|
||||||
}
|
|
||||||
catch (etl::array_out_of_range_exception)
|
|
||||||
{
|
|
||||||
gotException = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
CHECK(gotException);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
|
|||||||
@ -129,25 +129,12 @@ namespace
|
|||||||
{
|
{
|
||||||
etl::queue<int, 4> queue;
|
etl::queue<int, 4> queue;
|
||||||
|
|
||||||
bool gotException = false;
|
for (size_t i = 0; i < queue.capacity(); ++i)
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < queue.capacity() + 1; ++i)
|
queue.push(1);
|
||||||
{
|
|
||||||
queue.push(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (etl::queue_full_exception&)
|
|
||||||
{
|
|
||||||
gotException = true;
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
CHECK(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK(gotException);
|
CHECK_THROW(queue.push(1), etl::queue_full_exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
@ -203,22 +190,7 @@ namespace
|
|||||||
{
|
{
|
||||||
etl::queue<int, 4> queue;
|
etl::queue<int, 4> queue;
|
||||||
|
|
||||||
bool gotException = false;
|
CHECK_THROW(queue.front(), etl::queue_empty_exception);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
queue.front();
|
|
||||||
}
|
|
||||||
catch (etl::queue_empty_exception&)
|
|
||||||
{
|
|
||||||
gotException = true;
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
CHECK(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
CHECK(gotException);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
@ -257,22 +229,7 @@ namespace
|
|||||||
{
|
{
|
||||||
etl::queue<int, 4> queue;
|
etl::queue<int, 4> queue;
|
||||||
|
|
||||||
bool gotException = false;
|
CHECK_THROW(queue.back(), etl::queue_empty_exception);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
queue.back();
|
|
||||||
}
|
|
||||||
catch (etl::queue_empty_exception&)
|
|
||||||
{
|
|
||||||
gotException = true;
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
CHECK(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
CHECK(gotException);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
|
|||||||
@ -129,25 +129,12 @@ namespace
|
|||||||
{
|
{
|
||||||
etl::stack<int, 4> stack;
|
etl::stack<int, 4> stack;
|
||||||
|
|
||||||
bool gotException = false;
|
for (size_t i = 0; i < stack.capacity(); ++i)
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < stack.capacity() + 1; ++i)
|
stack.push(1);
|
||||||
{
|
|
||||||
stack.push(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (etl::stack_full_exception&)
|
|
||||||
{
|
|
||||||
gotException = true;
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
CHECK(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK(gotException);
|
CHECK_THROW(stack.push(1), etl::stack_full_exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
@ -203,22 +190,7 @@ namespace
|
|||||||
{
|
{
|
||||||
etl::stack<int, 4> stack;
|
etl::stack<int, 4> stack;
|
||||||
|
|
||||||
bool gotException = false;
|
CHECK_THROW(stack.top(), etl::stack_empty_exception);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
stack.top();
|
|
||||||
}
|
|
||||||
catch (etl::stack_empty_exception&)
|
|
||||||
{
|
|
||||||
gotException = true;
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
CHECK(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
CHECK(gotException);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user