summaryrefslogtreecommitdiff
path: root/src/mongo/unittest/unittest.h
diff options
context:
space:
mode:
authorScott Hernandez <scotthernandez@gmail.com>2016-06-29 14:05:14 -0400
committerScott Hernandez <scotthernandez@gmail.com>2016-06-30 15:12:52 -0400
commitaf59ee648f0d63eb8730ca33a24227f56040f934 (patch)
tree9dfd9c8941c2ba552d65bd71b95e10ce090c6ba4 /src/mongo/unittest/unittest.h
parentf3919fcaa84bc10597df41d250a7493e2b378bba (diff)
downloadmongo-af59ee648f0d63eb8730ca33a24227f56040f934.tar.gz
SERVER-23750: unit test cleanup
Diffstat (limited to 'src/mongo/unittest/unittest.h')
-rw-r--r--src/mongo/unittest/unittest.h33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/mongo/unittest/unittest.h b/src/mongo/unittest/unittest.h
index f385e0d7356..4b38e0d1cc2 100644
--- a/src/mongo/unittest/unittest.h
+++ b/src/mongo/unittest/unittest.h
@@ -157,18 +157,21 @@
* Behaves like ASSERT_THROWS, above, but also fails if PREDICATE(ex) for the throw exception, ex,
* is false.
*/
-#define ASSERT_THROWS_PRED(STATEMENT, EXCEPTION_TYPE, PREDICATE) \
- do { \
- try { \
- STATEMENT; \
- FAIL("Expected statement " #STATEMENT " to throw " #EXCEPTION_TYPE \
- " but it threw nothing."); \
- } catch (const EXCEPTION_TYPE& ex) { \
- if (!(PREDICATE(ex))) { \
- FAIL("Expected " #STATEMENT " to throw an exception of type " #EXCEPTION_TYPE \
- " where " #PREDICATE "(ex) was true, but it was false."); \
- } \
- } \
+#define ASSERT_THROWS_PRED(STATEMENT, EXCEPTION_TYPE, PREDICATE) \
+ do { \
+ try { \
+ STATEMENT; \
+ FAIL("Expected statement " #STATEMENT " to throw " #EXCEPTION_TYPE \
+ " but it threw nothing."); \
+ } catch (const EXCEPTION_TYPE& ex) { \
+ if (!(PREDICATE(ex))) { \
+ ::mongoutils::str::stream err; \
+ err << "Expected " #STATEMENT " to throw an exception of type " #EXCEPTION_TYPE \
+ " where " #PREDICATE "(ex) was true, but it was false: " \
+ << ex.what(); \
+ FAIL(err); \
+ } \
+ } \
} while (false)
#define ASSERT_STRING_CONTAINS(BIG_STRING, CONTAINS) \
@@ -176,7 +179,7 @@
std::string myString(BIG_STRING); \
std::string myContains(CONTAINS); \
if (myString.find(myContains) == std::string::npos) { \
- str::stream err; \
+ ::mongoutils::str::stream err; \
err << "Expected to find " #CONTAINS " (" << myContains << ") in " #BIG_STRING " (" \
<< myString << ")"; \
::mongo::unittest::TestAssertionFailure(__FILE__, __LINE__, err).stream(); \
@@ -482,6 +485,10 @@ public:
_message = message;
}
+ const std::string& what() const {
+ return getMessage();
+ }
+
std::string toString() const;
private: