diff options
author | Bynn Lee <bynn.lee@mongodb.com> | 2021-02-17 22:34:59 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-02-22 17:28:27 +0000 |
commit | 3307ba57eef2dfff9abe2413e39058ac9451ec04 (patch) | |
tree | 57a7b6a482e927176823a39a671ac9fdd832d062 /src/mongo/dbtests | |
parent | bfbf776563bf16a6a52ffcc0a69f4686953eb0a1 (diff) | |
download | mongo-3307ba57eef2dfff9abe2413e39058ac9451ec04.tar.gz |
SERVER-43762 tighten the overload set for BSONObjBuilder::appendNumber
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r-- | src/mongo/dbtests/jsobjtests.cpp | 46 | ||||
-rw-r--r-- | src/mongo/dbtests/mock/mock_replica_set.cpp | 4 |
2 files changed, 3 insertions, 47 deletions
diff --git a/src/mongo/dbtests/jsobjtests.cpp b/src/mongo/dbtests/jsobjtests.cpp index c3e754b8771..99f984e0c87 100644 --- a/src/mongo/dbtests/jsobjtests.cpp +++ b/src/mongo/dbtests/jsobjtests.cpp @@ -561,49 +561,6 @@ 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; @@ -619,7 +576,7 @@ struct AppendNumber { ASSERT(o["a"].type() == NumberInt); ASSERT(o["b"].type() == NumberDouble); ASSERT(o["c"].type() == NumberInt); - ASSERT(o["d"].type() == NumberDouble); + ASSERT(o["d"].type() == NumberLong); ASSERT(o["e"].type() == NumberLong); ASSERT(o["f"].type() == NumberDecimal); } @@ -2008,7 +1965,6 @@ 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 53fd2d0a8cd..358c880de45 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.appendIntOrLL("secondaryDelaySecs", - durationCount<Seconds>(member->getSecondaryDelay())); + builder.appendNumber("secondaryDelaySecs", + durationCount<Seconds>(member->getSecondaryDelay())); } if (member->isHidden()) { |