summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests
diff options
context:
space:
mode:
authorBynn Lee <bynn.lee@mongodb.com>2021-02-24 21:34:16 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-02-25 01:55:59 +0000
commitb8107b8e481ae7073d30304196a3028145c80634 (patch)
treecc954ce4d68fd790a38ef7f1fecc825c14f6d9b6 /src/mongo/dbtests
parentbff2d6e263a19c85eca7058ceb829ff55b1e2d63 (diff)
downloadmongo-b8107b8e481ae7073d30304196a3028145c80634.tar.gz
Revert "SERVER-43762 tighten the overload set for BSONObjBuilder::appendNumber"
This reverts commit 3307ba57eef2dfff9abe2413e39058ac9451ec04.
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r--src/mongo/dbtests/jsobjtests.cpp46
-rw-r--r--src/mongo/dbtests/mock/mock_replica_set.cpp4
2 files changed, 47 insertions, 3 deletions
diff --git a/src/mongo/dbtests/jsobjtests.cpp b/src/mongo/dbtests/jsobjtests.cpp
index 99f984e0c87..c3e754b8771 100644
--- a/src/mongo/dbtests/jsobjtests.cpp
+++ b/src/mongo/dbtests/jsobjtests.cpp
@@ -561,6 +561,49 @@ public:
}
};
+struct AppendIntOrLL {
+ void run() {
+ const long long billion = 1000 * 1000 * 1000;
+
+ BSONObjBuilder b;
+ b.appendIntOrLL("i1", 1);
+ b.appendIntOrLL("i2", -1);
+ b.appendIntOrLL("i3", 1 * billion);
+ b.appendIntOrLL("i4", -1 * billion);
+
+ b.appendIntOrLL("L1", 2 * billion);
+ b.appendIntOrLL("L2", -2 * billion);
+ b.appendIntOrLL("L3", 4 * billion);
+ b.appendIntOrLL("L4", -4 * billion);
+ b.appendIntOrLL("L5", 16 * billion);
+ b.appendIntOrLL("L6", -16 * billion);
+
+ BSONObj o = b.obj();
+
+ ASSERT(o["i1"].type() == NumberInt);
+ ASSERT(o["i1"].number() == 1);
+ ASSERT(o["i2"].type() == NumberInt);
+ ASSERT(o["i2"].number() == -1);
+ ASSERT(o["i3"].type() == NumberInt);
+ ASSERT(o["i3"].number() == 1 * billion);
+ ASSERT(o["i4"].type() == NumberInt);
+ ASSERT(o["i4"].number() == -1 * billion);
+
+ ASSERT(o["L1"].isNumber());
+ ASSERT(o["L1"].number() == 2 * billion);
+ ASSERT(o["L2"].isNumber());
+ ASSERT(o["L2"].number() == -2 * billion);
+ ASSERT(o["L3"].type() == NumberLong);
+ ASSERT(o["L3"].number() == 4 * billion);
+ ASSERT(o["L4"].type() == NumberLong);
+ ASSERT(o["L4"].number() == -4 * billion);
+ ASSERT(o["L5"].type() == NumberLong);
+ ASSERT(o["L5"].number() == 16 * billion);
+ ASSERT(o["L6"].type() == NumberLong);
+ ASSERT(o["L6"].number() == -16 * billion);
+ }
+};
+
struct AppendNumber {
void run() {
BSONObjBuilder b;
@@ -576,7 +619,7 @@ struct AppendNumber {
ASSERT(o["a"].type() == NumberInt);
ASSERT(o["b"].type() == NumberDouble);
ASSERT(o["c"].type() == NumberInt);
- ASSERT(o["d"].type() == NumberLong);
+ ASSERT(o["d"].type() == NumberDouble);
ASSERT(o["e"].type() == NumberLong);
ASSERT(o["f"].type() == NumberDecimal);
}
@@ -1965,6 +2008,7 @@ public:
add<BSONObjTests::MultiKeySortOrder>();
add<BSONObjTests::Nan>();
add<BSONObjTests::AsTempObj>();
+ add<BSONObjTests::AppendIntOrLL>();
add<BSONObjTests::AppendNumber>();
add<BSONObjTests::ToStringNumber>();
add<BSONObjTests::AppendAs>();
diff --git a/src/mongo/dbtests/mock/mock_replica_set.cpp b/src/mongo/dbtests/mock/mock_replica_set.cpp
index 358c880de45..53fd2d0a8cd 100644
--- a/src/mongo/dbtests/mock/mock_replica_set.cpp
+++ b/src/mongo/dbtests/mock/mock_replica_set.cpp
@@ -249,8 +249,8 @@ void MockReplicaSet::mockIsMasterCmd() {
}
if (member->getSecondaryDelay().count()) {
- builder.appendNumber("secondaryDelaySecs",
- durationCount<Seconds>(member->getSecondaryDelay()));
+ builder.appendIntOrLL("secondaryDelaySecs",
+ durationCount<Seconds>(member->getSecondaryDelay()));
}
if (member->isHidden()) {