summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2017-01-26 17:28:25 -0500
committerMathias Stearn <mathias@10gen.com>2017-02-22 19:03:06 -0500
commit20af425dabe7201c8a48d748b4e9d6bed086372e (patch)
tree3d11d67b308f67d433e321a761f722c61a6f9e58
parent6cb066eb2b7c7f94f42cf68d2ddfc16999c1b8a3 (diff)
downloadmongo-20af425dabe7201c8a48d748b4e9d6bed086372e.tar.gz
SERVER-19249 Stringify arguments in ASSERT_BSON* before they are macro-expanded
before: TestName Expected [ ((::mongo::BSONObjBuilder(64) << "a" << 1).obj()) == ((::mongo::BSONObjBuilder(64) << "a" << 2).obj()) ] but found [ { a: 1 } == { a: 2 }] @file:123 after: TestName Expected [ BSON("a" << 1) == BSON("a" << 2) ] but found [ { a: 1 } == { a: 2 }] @file:123
-rw-r--r--src/mongo/unittest/bson_test_util.h28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/mongo/unittest/bson_test_util.h b/src/mongo/unittest/bson_test_util.h
index a70af117f35..108ce7ec7d8 100644
--- a/src/mongo/unittest/bson_test_util.h
+++ b/src/mongo/unittest/bson_test_util.h
@@ -35,28 +35,28 @@
/**
* BSON comparison utility macro. Do not use directly.
*/
-#define ASSERT_BSON_COMPARISON(NAME, a, b) \
- ::mongo::unittest::assertComparison_##NAME(__FILE__, __LINE__, #a, #b, a, b)
+#define ASSERT_BSON_COMPARISON(NAME, a, b, astr, bstr) \
+ ::mongo::unittest::assertComparison_##NAME(__FILE__, __LINE__, astr, bstr, a, b)
/**
* Use to compare two instances of type BSONObj under the default comparator in unit tests.
*/
-#define ASSERT_BSONOBJ_EQ(a, b) ASSERT_BSON_COMPARISON(BSONObjEQ, a, b)
-#define ASSERT_BSONOBJ_LT(a, b) ASSERT_BSON_COMPARISON(BSONObjLT, a, b)
-#define ASSERT_BSONOBJ_LTE(a, b) ASSERT_BSON_COMPARISON(BSONObjLTE, a, b)
-#define ASSERT_BSONOBJ_GT(a, b) ASSERT_BSON_COMPARISON(BSONObjGT, a, b)
-#define ASSERT_BSONOBJ_GTE(a, b) ASSERT_BSON_COMPARISON(BSONObjGTE, a, b)
-#define ASSERT_BSONOBJ_NE(a, b) ASSERT_BSON_COMPARISON(BSONObjNE, a, b)
+#define ASSERT_BSONOBJ_EQ(a, b) ASSERT_BSON_COMPARISON(BSONObjEQ, a, b, #a, #b)
+#define ASSERT_BSONOBJ_LT(a, b) ASSERT_BSON_COMPARISON(BSONObjLT, a, b, #a, #b)
+#define ASSERT_BSONOBJ_LTE(a, b) ASSERT_BSON_COMPARISON(BSONObjLTE, a, b, #a, #b)
+#define ASSERT_BSONOBJ_GT(a, b) ASSERT_BSON_COMPARISON(BSONObjGT, a, b, #a, #b)
+#define ASSERT_BSONOBJ_GTE(a, b) ASSERT_BSON_COMPARISON(BSONObjGTE, a, b, #a, #b)
+#define ASSERT_BSONOBJ_NE(a, b) ASSERT_BSON_COMPARISON(BSONObjNE, a, b, #a, #b)
/**
* Use to compare two instances of type BSONElement under the default comparator in unit tests.
*/
-#define ASSERT_BSONELT_EQ(a, b) ASSERT_BSON_COMPARISON(BSONElementEQ, a, b)
-#define ASSERT_BSONELT_LT(a, b) ASSERT_BSON_COMPARISON(BSONElementLT, a, b)
-#define ASSERT_BSONELT_LTE(a, b) ASSERT_BSON_COMPARISON(BSONElementLTE, a, b)
-#define ASSERT_BSONELT_GT(a, b) ASSERT_BSON_COMPARISON(BSONElementGT, a, b)
-#define ASSERT_BSONELT_GTE(a, b) ASSERT_BSON_COMPARISON(BSONElementGTE, a, b)
-#define ASSERT_BSONELT_NE(a, b) ASSERT_BSON_COMPARISON(BSONElementNE, a, b)
+#define ASSERT_BSONELT_EQ(a, b) ASSERT_BSON_COMPARISON(BSONElementEQ, a, b, #a, #b)
+#define ASSERT_BSONELT_LT(a, b) ASSERT_BSON_COMPARISON(BSONElementLT, a, b, #a, #b)
+#define ASSERT_BSONELT_LTE(a, b) ASSERT_BSON_COMPARISON(BSONElementLTE, a, b, #a, #b)
+#define ASSERT_BSONELT_GT(a, b) ASSERT_BSON_COMPARISON(BSONElementGT, a, b, #a, #b)
+#define ASSERT_BSONELT_GTE(a, b) ASSERT_BSON_COMPARISON(BSONElementGTE, a, b, #a, #b)
+#define ASSERT_BSONELT_NE(a, b) ASSERT_BSON_COMPARISON(BSONElementNE, a, b, #a, #b)
namespace mongo {
namespace unittest {