diff options
author | Josh Blum <josh@joshknows.com> | 2011-06-25 20:22:12 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-06-25 20:22:12 -0700 |
commit | b8d0dc0918c90c03b5e69593c8f79b5457aa5d7a (patch) | |
tree | a5003aa4e1e44b619b41e0b819700b09fc65cee5 /host/tests/error_test.cpp | |
parent | 58679377fba07be56548874ed117a76eae79e846 (diff) | |
parent | 25d6e39c6af61acde0616cf50178d40741c4eace (diff) | |
download | uhd-b8d0dc0918c90c03b5e69593c8f79b5457aa5d7a.tar.gz uhd-b8d0dc0918c90c03b5e69593c8f79b5457aa5d7a.tar.bz2 uhd-b8d0dc0918c90c03b5e69593c8f79b5457aa5d7a.zip |
Merge branch 'master' into next
Diffstat (limited to 'host/tests/error_test.cpp')
-rw-r--r-- | host/tests/error_test.cpp | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/host/tests/error_test.cpp b/host/tests/error_test.cpp index 983f0150c..3d784b1f7 100644 --- a/host/tests/error_test.cpp +++ b/host/tests/error_test.cpp @@ -44,7 +44,8 @@ BOOST_AUTO_TEST_CASE(test_assert_has){ std::cout << "The output of the assert_has error:" << std::endl; try{ uhd::assert_has(vec, 1, "prime"); - }catch(const std::exception &e){ + } + catch(const std::exception &e){ std::cout << e.what() << std::endl; } } @@ -53,7 +54,40 @@ BOOST_AUTO_TEST_CASE(test_assert_throw){ std::cout << "The output of the assert throw error:" << std::endl; try{ UHD_ASSERT_THROW(2 + 2 == 5); - }catch(const std::exception &e){ + } + catch(const std::exception &e){ std::cout << e.what() << std::endl; } } + +BOOST_AUTO_TEST_CASE(test_exception_dynamic){ + uhd::exception *exception_clone; + + //throw an exception and dynamically clone it + try{ + throw uhd::runtime_error("noooooo"); + } + catch(const uhd::exception &e){ + std::cout << e.what() << std::endl; + exception_clone = e.dynamic_clone(); + } + + //now we dynamically re-throw the exception + try{ + exception_clone->dynamic_throw(); + } + catch(const uhd::assertion_error &e){ + std::cout << e.what() << std::endl; + BOOST_CHECK(false); + } + catch(const uhd::runtime_error &e){ + std::cout << e.what() << std::endl; + BOOST_CHECK(true); + } + catch(const uhd::exception &e){ + std::cout << e.what() << std::endl; + BOOST_CHECK(false); + } + + delete exception_clone; //manual cleanup +} |