summaryrefslogtreecommitdiff
path: root/src/mongo/unittest
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2015-09-21 10:48:55 -0400
committerBenety Goh <benety@mongodb.com>2015-09-22 10:31:20 -0400
commit230005e3ac47b6278e22144af8d9ce417e3e1aa2 (patch)
tree858eff44a9254337bc7bdb49f15ff8c90dc2f7d9 /src/mongo/unittest
parent65c034766b1e84827f7b0715349d5586f2ec10b3 (diff)
downloadmongo-230005e3ac47b6278e22144af8d9ce417e3e1aa2.tar.gz
SERVER-7244 added tests for rolling back index creation and operations with no _id
Diffstat (limited to 'src/mongo/unittest')
-rw-r--r--src/mongo/unittest/unittest.cpp12
-rw-r--r--src/mongo/unittest/unittest.h5
2 files changed, 17 insertions, 0 deletions
diff --git a/src/mongo/unittest/unittest.cpp b/src/mongo/unittest/unittest.cpp
index b4e380abc26..dfe1ddd2c10 100644
--- a/src/mongo/unittest/unittest.cpp
+++ b/src/mongo/unittest/unittest.cpp
@@ -42,6 +42,7 @@
#include "mongo/logger/logger.h"
#include "mongo/logger/message_event_utf8_encoder.h"
#include "mongo/logger/message_log_domain.h"
+#include "mongo/stdx/functional.h"
#include "mongo/stdx/memory.h"
#include "mongo/stdx/mutex.h"
#include "mongo/util/assert_util.h"
@@ -56,6 +57,11 @@ using std::string;
namespace unittest {
namespace {
+
+bool stringContains(const std::string& haystack, const std::string& needle) {
+ return haystack.find(needle) != std::string::npos;
+}
+
logger::MessageLogDomain* unittestOutput = logger::globalLogManager()->getNamedDomain("unittest");
typedef std::map<std::string, std::shared_ptr<Suite>> SuiteMap;
@@ -209,6 +215,12 @@ void Test::stopCapturingLogMessages() {
_isCapturingLogMessages = false;
}
+int64_t Test::countLogLinesContaining(const std::string& needle) {
+ return std::count_if(getCapturedLogMessages().begin(),
+ getCapturedLogMessages().end(),
+ stdx::bind(stringContains, stdx::placeholders::_1, needle));
+}
+
Suite::Suite(const std::string& name) : _name(name) {
registerSuite(name, this);
}
diff --git a/src/mongo/unittest/unittest.h b/src/mongo/unittest/unittest.h
index 9c40621b3a4..8953681f428 100644
--- a/src/mongo/unittest/unittest.h
+++ b/src/mongo/unittest/unittest.h
@@ -319,6 +319,11 @@ protected:
return _capturedLogMessages;
}
+ /**
+ * Returns the number of collected log lines containing "needle".
+ */
+ int64_t countLogLinesContaining(const std::string& needle);
+
private:
/**
* Called on the test object before running the test.