summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatt dannenberg <matt.dannenberg@10gen.com>2014-09-04 09:58:51 -0400
committermatt dannenberg <matt.dannenberg@10gen.com>2014-09-05 10:39:31 -0400
commit9e4b2e503b907836f099fb3ee239e00317e0a01b (patch)
treefb726625dc720251f5bfdbe4d6b9f245b87c384a
parent795b908290794af543f838cd08a04c4871a54c83 (diff)
downloadmongo-9e4b2e503b907836f099fb3ee239e00317e0a01b.tar.gz
SERVER-15147 move Date_t and OpTime ostreaming to unittest
-rw-r--r--src/mongo/db/repl/repl_coordinator_impl_test.cpp12
-rw-r--r--src/mongo/db/repl/repl_set_heartbeat_response_test.cpp12
-rw-r--r--src/mongo/db/repl/topology_coordinator_impl_test.cpp12
-rw-r--r--src/mongo/unittest/SConscript7
-rw-r--r--src/mongo/unittest/unittest.h1
-rw-r--r--src/mongo/unittest/unittest_helpers.cpp49
-rw-r--r--src/mongo/unittest/unittest_helpers.h43
7 files changed, 99 insertions, 37 deletions
diff --git a/src/mongo/db/repl/repl_coordinator_impl_test.cpp b/src/mongo/db/repl/repl_coordinator_impl_test.cpp
index 5ffd801ce84..32a7532c138 100644
--- a/src/mongo/db/repl/repl_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/repl_coordinator_impl_test.cpp
@@ -52,18 +52,6 @@
#include "mongo/util/log.h"
namespace mongo {
-
- // So that you can ASSERT_EQUALS two OpTimes
- std::ostream& operator<<( std::ostream &s, const OpTime &ot ) {
- s << ot.toString();
- return s;
- }
- // So that you can ASSERT_EQUALS two Date_ts
- std::ostream& operator<<( std::ostream &s, const Date_t &t ) {
- s << t.toString();
- return s;
- }
-
namespace repl {
namespace {
diff --git a/src/mongo/db/repl/repl_set_heartbeat_response_test.cpp b/src/mongo/db/repl/repl_set_heartbeat_response_test.cpp
index 7742826f4fd..4e1981e7bfc 100644
--- a/src/mongo/db/repl/repl_set_heartbeat_response_test.cpp
+++ b/src/mongo/db/repl/repl_set_heartbeat_response_test.cpp
@@ -33,18 +33,6 @@
#include "mongo/db/repl/repl_set_heartbeat_response.h"
namespace mongo {
-
- // So that you can ASSERT_EQUALS two OpTimes
- std::ostream& operator<<( std::ostream &s, const OpTime &ot ) {
- s << ot.toString();
- return s;
- }
- // So that you can ASSERT_EQUALS two Date_ts
- std::ostream& operator<<( std::ostream &s, const Date_t &t ) {
- s << t.toString();
- return s;
- }
-
namespace repl {
namespace {
diff --git a/src/mongo/db/repl/topology_coordinator_impl_test.cpp b/src/mongo/db/repl/topology_coordinator_impl_test.cpp
index 47dba5b773d..77f49e6572f 100644
--- a/src/mongo/db/repl/topology_coordinator_impl_test.cpp
+++ b/src/mongo/db/repl/topology_coordinator_impl_test.cpp
@@ -41,18 +41,6 @@
ASSERT_EQUALS(mongo::repl::TopologyCoordinator::HeartbeatResponseAction::NoAction, (EXPRESSION))
namespace mongo {
-
- // So that you can ASSERT_EQUALS two OpTimes
- std::ostream& operator<<( std::ostream &s, const OpTime &ot ) {
- s << ot.toString();
- return s;
- }
- // So that you can ASSERT_EQUALS two Date_ts
- std::ostream& operator<<( std::ostream &s, const Date_t &t ) {
- s << t.toString();
- return s;
- }
-
namespace repl {
namespace {
diff --git a/src/mongo/unittest/SConscript b/src/mongo/unittest/SConscript
index a835fb691fd..bec5a5f0e09 100644
--- a/src/mongo/unittest/SConscript
+++ b/src/mongo/unittest/SConscript
@@ -2,7 +2,12 @@
Import("env")
-env.Library("unittest", ['unittest.cpp', 'temp_dir.cpp'],
+env.Library(target="unittest",
+ source=[
+ 'unittest.cpp',
+ 'temp_dir.cpp',
+ 'unittest_helpers.cpp',
+ ],
LIBDEPS=['$BUILD_DIR/mongo/foundation',
'$BUILD_DIR/mongo/util/options_parser/options_parser',
])
diff --git a/src/mongo/unittest/unittest.h b/src/mongo/unittest/unittest.h
index ccef6dc9925..a7a1c1a9b60 100644
--- a/src/mongo/unittest/unittest.h
+++ b/src/mongo/unittest/unittest.h
@@ -47,6 +47,7 @@
#include "mongo/logger/logstream_builder.h"
#include "mongo/logger/message_log_domain.h"
#include "mongo/stdx/functional.h"
+#include "mongo/unittest/unittest_helpers.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/mongoutils/str.h"
diff --git a/src/mongo/unittest/unittest_helpers.cpp b/src/mongo/unittest/unittest_helpers.cpp
new file mode 100644
index 00000000000..9931a6a8d23
--- /dev/null
+++ b/src/mongo/unittest/unittest_helpers.cpp
@@ -0,0 +1,49 @@
+/**
+ * Copyright (C) 2014 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects
+ * for all of the code used other than as permitted herein. If you modify
+ * file(s) with this exception, you may extend this exception to your
+ * version of the file(s), but you are not obligated to do so. If you do not
+ * wish to do so, delete this exception statement from your version. If you
+ * delete this exception statement from all source files in the program,
+ * then also delete it in the license file.
+ */
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/unittest/unittest_helpers.h"
+
+#include <ostream>
+
+#include "mongo/bson/optime.h"
+#include "mongo/util/time_support.h"
+
+namespace mongo {
+
+ std::ostream& operator<<(std::ostream &s, const OpTime &ot) {
+ s << ot.toString();
+ return s;
+ }
+
+ std::ostream& operator<<(std::ostream &s, const Date_t &t) {
+ s << t.toString();
+ return s;
+ }
+}
diff --git a/src/mongo/unittest/unittest_helpers.h b/src/mongo/unittest/unittest_helpers.h
new file mode 100644
index 00000000000..0bcf4adb84f
--- /dev/null
+++ b/src/mongo/unittest/unittest_helpers.h
@@ -0,0 +1,43 @@
+/**
+ * Copyright (C) 2014 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects
+ * for all of the code used other than as permitted herein. If you modify
+ * file(s) with this exception, you may extend this exception to your
+ * version of the file(s), but you are not obligated to do so. If you do not
+ * wish to do so, delete this exception statement from your version. If you
+ * delete this exception statement from all source files in the program,
+ * then also delete it in the license file.
+ */
+
+#pragma once
+
+#include <ostream>
+
+namespace mongo {
+ class OpTime;
+ struct Date_t;
+
+ // So that you can ASSERT_EQUALS two OpTimes
+ std::ostream& operator<<(std::ostream& s, const OpTime& ot);
+
+ // So that you can ASSERT_EQUALS two Date_ts
+ std::ostream& operator<<(std::ostream& s, const Date_t& t);
+
+} // namespace mongo