diff --git a/test/test_array.cpp b/test/test_array.cpp index e4ab60fc..a71a9857 100644 --- a/test/test_array.cpp +++ b/test/test_array.cpp @@ -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); } //************************************************************************* diff --git a/test/test_queue.cpp b/test/test_queue.cpp index 2b63f11b..2af10aa2 100644 --- a/test/test_queue.cpp +++ b/test/test_queue.cpp @@ -129,25 +129,12 @@ namespace { etl::queue 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 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 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); } //************************************************************************* diff --git a/test/test_stack.cpp b/test/test_stack.cpp index d4d1420b..4e4f99eb 100644 --- a/test/test_stack.cpp +++ b/test/test_stack.cpp @@ -129,25 +129,12 @@ namespace { etl::stack 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 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); } //*************************************************************************