diff options
Diffstat (limited to 'src/mongo/bson')
-rw-r--r-- | src/mongo/bson/oid_test.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/bson/oid_test.cpp b/src/mongo/bson/oid_test.cpp index 7a0e6d6773d..8be156ae41d 100644 --- a/src/mongo/bson/oid_test.cpp +++ b/src/mongo/bson/oid_test.cpp @@ -149,4 +149,16 @@ TEST(Basic, FromStringToString) { std::string fromStr("541b1a00e8a23afa832b218e"); ASSERT_EQUALS(OID(fromStr).toString(), fromStr); } + +TEST(Basic, FromTerm) { + auto term = 7; + auto oid = OID::fromTerm(term); + + auto oidStr = oid.toString(); + auto oidHead = oidStr.substr(0, 8); + auto oidTail = oidStr.substr(oidStr.length() - 1); + + ASSERT_EQUALS("7fffffff", oidHead); + ASSERT_EQUALS(term, std::stoi(oidTail)); +} } |