summaryrefslogtreecommitdiff
path: root/src/mongo/unittest/unittest.h
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2014-07-01 16:37:40 -0400
committerAndy Schwerin <schwerin@mongodb.com>2014-07-02 14:18:19 -0400
commit8ad0bf94e69d09ab3bbb02e5493e69e7e392b0c3 (patch)
treef27a17b2579dcbfa0dd099915be2d906e77b491a /src/mongo/unittest/unittest.h
parentf1a3238f53ed4d0d071edc5d9db51c90ffa78f78 (diff)
downloadmongo-8ad0bf94e69d09ab3bbb02e5493e69e7e392b0c3.tar.gz
SERVER-14418 Introduce unittest::assertGet, use in replication_executor_test.
Diffstat (limited to 'src/mongo/unittest/unittest.h')
-rw-r--r--src/mongo/unittest/unittest.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mongo/unittest/unittest.h b/src/mongo/unittest/unittest.h
index 69849fca5f9..bc60e20f651 100644
--- a/src/mongo/unittest/unittest.h
+++ b/src/mongo/unittest/unittest.h
@@ -43,6 +43,7 @@
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
+#include "mongo/base/status_with.h"
#include "mongo/logger/logstream_builder.h"
#include "mongo/stdx/functional.h"
#include "mongo/util/assert_util.h"
@@ -461,6 +462,15 @@ namespace mongo {
}
/**
+ * Get the value out of a StatusWith<T>, or throw an exception if it is not OK.
+ */
+ template <typename T>
+ const T& assertGet(const StatusWith<T>& swt) {
+ ASSERT_OK(swt.getStatus());
+ return swt.getValue();
+ }
+
+ /**
* Hack to support the runaway test observer in dbtests. This is a hook that
* unit test running harnesses (unittest_main and dbtests) must implement.
*/