diff options
author | Billy Donahue <BillyDonahue@users.noreply.github.com> | 2022-07-27 18:17:24 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-07-27 19:38:08 +0000 |
commit | 958ad9abfc80861d3f43f44da694e83464b01e1d (patch) | |
tree | ca14e7097c1cb8ab20dfad7fa6888511f0226650 /src/mongo/bson | |
parent | f8a1ac19be6279e7ace012dafa8cfcaa028d49e1 (diff) | |
download | mongo-958ad9abfc80861d3f43f44da694e83464b01e1d.tar.gz |
SERVER-68246 rewrite calls to boost::optional get and is_initialized
Diffstat (limited to 'src/mongo/bson')
-rw-r--r-- | src/mongo/bson/util/simple8b_type_util_test.cpp | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/src/mongo/bson/util/simple8b_type_util_test.cpp b/src/mongo/bson/util/simple8b_type_util_test.cpp index bd2ed7e1038..c8775cdfd3b 100644 --- a/src/mongo/bson/util/simple8b_type_util_test.cpp +++ b/src/mongo/bson/util/simple8b_type_util_test.cpp @@ -144,11 +144,11 @@ TEST(Simple8bTypeUtil, DecimalPositiveValue) { double val = 1.0; boost::optional<uint8_t> scalar = Simple8bTypeUtil::calculateDecimalShiftMultiplier(val); ASSERT_TRUE(scalar); - ASSERT_EQUALS(scalar.get(), scaleIndexForMultiplier(1)); - boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.get()); + ASSERT_EQUALS(scalar.value(), scaleIndexForMultiplier(1)); + boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.value()); ASSERT_TRUE(encodeResult); - ASSERT_EQUALS(encodeResult.get(), 1); - double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.get(), scalar.get()); + ASSERT_EQUALS(encodeResult.value(), 1); + double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.value(), scalar.value()); ASSERT_EQUALS(val, decodeResult); } @@ -156,11 +156,11 @@ TEST(Simple8bTypeUtil, EightDigitDecimalValue) { double val = 1.12345678; boost::optional<uint8_t> scalar = Simple8bTypeUtil::calculateDecimalShiftMultiplier(val); ASSERT_TRUE(scalar); - ASSERT_EQUALS(scalar.get(), scaleIndexForMultiplier(100000000)); - boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.get()); + ASSERT_EQUALS(scalar.value(), scaleIndexForMultiplier(100000000)); + boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.value()); ASSERT_TRUE(encodeResult); - ASSERT_EQUALS(encodeResult.get(), 112345678); - double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.get(), scalar.get()); + ASSERT_EQUALS(encodeResult.value(), 112345678); + double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.value(), scalar.value()); ASSERT_EQUALS(val, decodeResult); } @@ -168,11 +168,11 @@ TEST(Simple8bTypeUtil, TwoDigitDecimalValue) { double val = 1.12; boost::optional<uint8_t> scalar = Simple8bTypeUtil::calculateDecimalShiftMultiplier(val); ASSERT_TRUE(scalar); - ASSERT_EQUALS(scalar.get(), scaleIndexForMultiplier(100)); - boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.get()); + ASSERT_EQUALS(scalar.value(), scaleIndexForMultiplier(100)); + boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.value()); ASSERT_TRUE(encodeResult); - ASSERT_EQUALS(encodeResult.get(), 112); - double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.get(), scalar.get()); + ASSERT_EQUALS(encodeResult.value(), 112); + double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.value(), scalar.value()); ASSERT_EQUALS(val, decodeResult); } @@ -186,11 +186,11 @@ TEST(Simple8bTypeUtil, SparseDecimalValue) { double val = 1.00000001; boost::optional<uint8_t> scalar = Simple8bTypeUtil::calculateDecimalShiftMultiplier(val); ASSERT_TRUE(scalar); - ASSERT_EQUALS(scalar.get(), scaleIndexForMultiplier(100000000)); - boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.get()); + ASSERT_EQUALS(scalar.value(), scaleIndexForMultiplier(100000000)); + boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.value()); ASSERT_TRUE(encodeResult); - ASSERT_EQUALS(encodeResult.get(), 100000001); - double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.get(), scalar.get()); + ASSERT_EQUALS(encodeResult.value(), 100000001); + double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.value(), scalar.value()); ASSERT_EQUALS(val, decodeResult); } @@ -198,11 +198,11 @@ TEST(Simple8bTypeUtil, RoundingDecimalValue) { double val = 1.455454; boost::optional<uint8_t> scalar = Simple8bTypeUtil::calculateDecimalShiftMultiplier(val); ASSERT_TRUE(scalar); - ASSERT_EQUALS(scalar.get(), scaleIndexForMultiplier(100000000)); - boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.get()); + ASSERT_EQUALS(scalar.value(), scaleIndexForMultiplier(100000000)); + boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.value()); ASSERT_TRUE(encodeResult); - ASSERT_EQUALS(encodeResult.get(), 145545400); - double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.get(), scalar.get()); + ASSERT_EQUALS(encodeResult.value(), 145545400); + double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.value(), scalar.value()); ASSERT_EQUALS(val, decodeResult); } @@ -210,11 +210,11 @@ TEST(Simple8bTypeUtil, AllNines) { double val = 1.99999999; boost::optional<uint8_t> scalar = Simple8bTypeUtil::calculateDecimalShiftMultiplier(val); ASSERT_TRUE(scalar); - ASSERT_EQUALS(scalar.get(), scaleIndexForMultiplier(100000000)); - boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.get()); + ASSERT_EQUALS(scalar.value(), scaleIndexForMultiplier(100000000)); + boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.value()); ASSERT_TRUE(encodeResult); - ASSERT_EQUALS(encodeResult.get(), 199999999); - double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.get(), scalar.get()); + ASSERT_EQUALS(encodeResult.value(), 199999999); + double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.value(), scalar.value()); ASSERT_EQUALS(val, decodeResult); } @@ -222,11 +222,11 @@ TEST(Simple8bTypeUtil, 3DigitValue) { double val = 123.123; boost::optional<uint8_t> scalar = Simple8bTypeUtil::calculateDecimalShiftMultiplier(val); ASSERT_TRUE(scalar); - ASSERT_EQUALS(scalar.get(), scaleIndexForMultiplier(10000)); - boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.get()); + ASSERT_EQUALS(scalar.value(), scaleIndexForMultiplier(10000)); + boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.value()); ASSERT_TRUE(encodeResult); - ASSERT_EQUALS(encodeResult.get(), (1231230)); - double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.get(), scalar.get()); + ASSERT_EQUALS(encodeResult.value(), (1231230)); + double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.value(), scalar.value()); ASSERT_EQUALS(val, decodeResult); } @@ -301,12 +301,12 @@ TEST(Simple8bTypeUtil, TestMaxInt) { double val = std::pow(2, 53); boost::optional<uint8_t> scalar = Simple8bTypeUtil::calculateDecimalShiftMultiplier(val); ASSERT_TRUE(scalar); - ASSERT_EQUALS(scalar.get(), scaleIndexForMultiplier(1)); - boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.get()); + ASSERT_EQUALS(scalar.value(), scaleIndexForMultiplier(1)); + boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.value()); ASSERT_TRUE(encodeResult); // Handle negative case - ASSERT_EQUALS(encodeResult.get(), int64_t(val)); - double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.get(), scalar.get()); + ASSERT_EQUALS(encodeResult.value(), int64_t(val)); + double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.value(), scalar.value()); ASSERT_EQUALS(val, decodeResult); } @@ -314,12 +314,12 @@ TEST(Simple8bTypeUtil, NegativeValue) { double val = -123.123; boost::optional<uint8_t> scalar = Simple8bTypeUtil::calculateDecimalShiftMultiplier(val); ASSERT_TRUE(scalar); - ASSERT_EQUALS(scalar.get(), scaleIndexForMultiplier(10000)); - boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.get()); + ASSERT_EQUALS(scalar.value(), scaleIndexForMultiplier(10000)); + boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.value()); ASSERT_TRUE(encodeResult); // Handle negative case - ASSERT_EQUALS(encodeResult.get(), -1231230); - double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.get(), scalar.get()); + ASSERT_EQUALS(encodeResult.value(), -1231230); + double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.value(), scalar.value()); ASSERT_EQUALS(val, decodeResult); } @@ -327,12 +327,12 @@ TEST(Simple8bTypeUtil, NegativeSixDecimalValue) { double val = -123.123456; boost::optional<uint8_t> scalar = Simple8bTypeUtil::calculateDecimalShiftMultiplier(val); ASSERT_TRUE(scalar); - ASSERT_EQUALS(scalar.get(), scaleIndexForMultiplier(100000000)); - boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.get()); + ASSERT_EQUALS(scalar.value(), scaleIndexForMultiplier(100000000)); + boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.value()); ASSERT_TRUE(encodeResult); // Handle negative case by subtracting 1 - ASSERT_EQUALS(encodeResult.get(), -12312345600); - double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.get(), scalar.get()); + ASSERT_EQUALS(encodeResult.value(), -12312345600); + double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.value(), scalar.value()); ASSERT_EQUALS(val, decodeResult); } @@ -341,12 +341,12 @@ TEST(Simple8bTypeUtil, TestMinInt) { double val = -std::pow(2, 53); boost::optional<std::uint8_t> scalar = Simple8bTypeUtil::calculateDecimalShiftMultiplier(val); ASSERT_TRUE(scalar); - ASSERT_EQUALS(scalar.get(), scaleIndexForMultiplier(1)); - boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.get()); + ASSERT_EQUALS(scalar.value(), scaleIndexForMultiplier(1)); + boost::optional<int64_t> encodeResult = Simple8bTypeUtil::encodeDouble(val, scalar.value()); ASSERT_TRUE(encodeResult); // Handle negative case - ASSERT_EQUALS(encodeResult.get(), int64_t(val)); - double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.get(), scalar.get()); + ASSERT_EQUALS(encodeResult.value(), int64_t(val)); + double decodeResult = Simple8bTypeUtil::decodeDouble(encodeResult.value(), scalar.value()); ASSERT_EQUALS(val, decodeResult); } |