diff options
author | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2019-06-03 21:57:55 -0400 |
---|---|---|
committer | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2019-06-13 17:08:17 -0400 |
commit | 668100df7982fd1ae3777fcf069de13253a05133 (patch) | |
tree | 90c767a2078dcb68df94ea2d891575e1301b1bb0 /src/mongo/util | |
parent | fffb564422ebf4d0569052ebe61bd96e6494e25f (diff) | |
download | mongo-668100df7982fd1ae3777fcf069de13253a05133.tar.gz |
SERVER-24374 Make Decimal128 integer ctors constexpr
Diffstat (limited to 'src/mongo/util')
-rw-r--r-- | src/mongo/util/represent_as_test.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/mongo/util/represent_as_test.cpp b/src/mongo/util/represent_as_test.cpp index bab9ba3ca53..08532599694 100644 --- a/src/mongo/util/represent_as_test.cpp +++ b/src/mongo/util/represent_as_test.cpp @@ -30,6 +30,7 @@ #include "mongo/platform/basic.h" #include <cmath> +#include <fmt/format.h> #include <limits> #include <type_traits> @@ -43,6 +44,8 @@ namespace mongo { namespace { +using namespace fmt::literals; + // Char values const signed char kCharMax = std::numeric_limits<signed char>::max(); const int kCharMaxAsInt = kCharMax; @@ -354,8 +357,15 @@ void integerToDecimal128() { v.emplace_back(-5); } - for (const auto& n : v) { - ASSERT(representAs<Decimal128>(n)->isEqual(Decimal128(std::to_string(n)))); + for (const Integer n : v) { + auto d = representAs<Decimal128>(n); + ASSERT(d); + if (!d->isEqual(Decimal128(std::to_string(n)))) { + FAIL( + "Failed expectation, representAs<Decimal128>({}) == Decimal128({})," + " but !Decimal128({}).isEqual(Decimal128(std::to_string({}))"_format( + n, d->toString(), d->toString(), n)); + } } } |