Modified unit tests to use CHECK_THROW

This commit is contained in:
jwellbelove 2014-10-31 15:59:22 +00:00
parent 585b494aa1
commit 4e2bfb2740
3 changed files with 11 additions and 104 deletions

View File

@ -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);
}
//*************************************************************************

View File

@ -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);
}
//*************************************************************************

View File

@ -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);
}
//*************************************************************************