summaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/unwind_message
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2021-03-22 12:12:14 +0000
committerHåvard Pettersen <havardpe@oath.com>2021-03-22 12:12:14 +0000
commit5c752cb2a5965110234a3e132b40bc24d6ec4dd9 (patch)
treeb7eb0febf87db27de9e13c63b44375c345f5fdbd /vespalib/src/tests/unwind_message
parent24977c3bf922cb70d8638ad2890075169954c987 (diff)
added UNWIND_DO macro
Diffstat (limited to 'vespalib/src/tests/unwind_message')
-rw-r--r--vespalib/src/tests/unwind_message/unwind_message_test.cpp35
1 files changed, 29 insertions, 6 deletions
diff --git a/vespalib/src/tests/unwind_message/unwind_message_test.cpp b/vespalib/src/tests/unwind_message/unwind_message_test.cpp
index 079d0235eb2..84245189842 100644
--- a/vespalib/src/tests/unwind_message/unwind_message_test.cpp
+++ b/vespalib/src/tests/unwind_message/unwind_message_test.cpp
@@ -6,6 +6,7 @@
using vespalib::unwind_msg;
using vespalib::UnwindMessage;
+using E = std::invalid_argument;
//-----------------------------------------------------------------------------
@@ -21,7 +22,6 @@ struct MyObj {
UnwindMessage msg3 = UnwindMessage("this SHOULD be printed (2/4)");
~MyObj() {
EXPECT_EQ(std::uncaught_exceptions(), 1);
- using E = std::invalid_argument;
auto not_printed_1 = std::move(msg2);
try {
MyCheck my_check;
@@ -32,7 +32,6 @@ struct MyObj {
};
TEST(UnwindMessageTest, unwind_messages_are_printed_when_appropriate) {
- using E = std::invalid_argument;
auto not_printed_5 = unwind_msg("this should NOT be printed (%d)", 5);
UNWIND_MSG("this should NOT be printed (%d)", 4);
EXPECT_THROW(
@@ -51,11 +50,7 @@ TEST(UnwindMessageTest, unwind_messages_are_printed_when_appropriate) {
//-----------------------------------------------------------------------------
-// need make_string for VESPA_STRLOC macro
-#include <vespa/vespalib/util/stringfmt.h>
-
TEST(UnwindMessageTest, unwind_message_with_location) {
- using E = std::invalid_argument;
EXPECT_THROW(
{
UNWIND_MSG("%s message with location information", VESPA_STRLOC.c_str());
@@ -65,4 +60,32 @@ TEST(UnwindMessageTest, unwind_message_with_location) {
//-----------------------------------------------------------------------------
+void my_bad_call() {
+ throw E("just testing");
+}
+
+TEST(UnwindMessageTest, unwind_message_from_UNWIND_DO_macro_calling_a_function) {
+ EXPECT_THROW(
+ {
+ UNWIND_DO(my_bad_call());
+ }, E);
+}
+
+//-----------------------------------------------------------------------------
+
+TEST(UnwindMessageTest, unwind_message_from_UNWIND_DO_macro_with_inline_code) {
+ EXPECT_THROW(
+ {
+ UNWIND_DO(
+ int a = 1;
+ int b = 2;
+ int c = a + b;
+ (void) c;
+ throw E("oops");
+ );
+ }, E);
+}
+
+//-----------------------------------------------------------------------------
+
GTEST_MAIN_RUN_ALL_TESTS()