summaryrefslogtreecommitdiff
path: root/src/mongo/unittest/unittest.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/unittest/unittest.h')
-rw-r--r--src/mongo/unittest/unittest.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/mongo/unittest/unittest.h b/src/mongo/unittest/unittest.h
index 514a8e7d8d9..8e82eb5e06b 100644
--- a/src/mongo/unittest/unittest.h
+++ b/src/mongo/unittest/unittest.h
@@ -53,6 +53,7 @@
#include "mongo/unittest/bson_test_util.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/str.h"
+#include "mongo/util/synchronized_value.h"
/**
* Fail unconditionally, reporting the given message.
@@ -151,6 +152,21 @@
ASSERT_THROWS_WITH_CHECK(EXPRESSION, EXCEPTION_TYPE, ([](const EXCEPTION_TYPE&) {}))
/**
+ * Verify that the evaluation of "EXPRESSION" does not throw any exceptions.
+ *
+ * If "EXPRESSION" throws an exception the test is considered a failure and further evaluation
+ * halts.
+ */
+#define ASSERT_DOES_NOT_THROW(EXPRESSION) \
+ try { \
+ EXPRESSION; \
+ } catch (const AssertionException& e) { \
+ str::stream err; \
+ err << "Threw an exception incorrectly: " << e.toString(); \
+ FAIL(err); \
+ }
+
+/**
* Behaves like ASSERT_THROWS, above, but also fails if calling what() on the thrown exception
* does not return a string equal to EXPECTED_WHAT.
*/
@@ -649,7 +665,7 @@ protected:
* Gets a vector of strings, one log line per string, captured since
* the last call to startCapturingLogMessages() in this test.
*/
- const std::vector<std::string>& getCapturedTextFormatLogMessages() const;
+ std::vector<std::string> getCapturedTextFormatLogMessages() const;
std::vector<BSONObj> getCapturedBSONFormatLogMessages() const;
/**