summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests/jsontests.cpp
diff options
context:
space:
mode:
authorRaymond Jacobson <raymond.jacobson@10gen.com>2015-07-07 12:06:15 -0400
committerRaymond Jacobson <raymond.jacobson@10gen.com>2015-08-13 11:34:59 -0400
commit9a81b7f1a6a8e0773703f2007c5a7268eb182b91 (patch)
treef94e060e8ce1e9b2eec91b9360ed3fbe6c86463b /src/mongo/dbtests/jsontests.cpp
parentadadd67c2bc8260a6ed1ac74d27edb24c4855c13 (diff)
downloadmongo-9a81b7f1a6a8e0773703f2007c5a7268eb182b91.tar.gz
SERVER-19627 Add Decimal128 type support to mongo shell
Diffstat (limited to 'src/mongo/dbtests/jsontests.cpp')
-rw-r--r--src/mongo/dbtests/jsontests.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/mongo/dbtests/jsontests.cpp b/src/mongo/dbtests/jsontests.cpp
index b5bf68b6af6..b2a703fc78a 100644
--- a/src/mongo/dbtests/jsontests.cpp
+++ b/src/mongo/dbtests/jsontests.cpp
@@ -38,6 +38,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/json.h"
#include "mongo/dbtests/dbtests.h"
+#include "mongo/platform/decimal128.h"
#include "mongo/util/log.h"
@@ -201,6 +202,26 @@ public:
}
};
+class NumberDecimal {
+public:
+ void run() {
+ BSONObjBuilder b;
+ b.append("a", mongo::Decimal128("123456789.12345"));
+ ASSERT_EQUALS("{ \"a\" : NumberDecimal(\"123456789.12345\") }",
+ b.done().jsonString(TenGen));
+ }
+};
+
+class NumberDecimalStrict {
+public:
+ void run() {
+ BSONObjBuilder b;
+ b.append("a", mongo::Decimal128("123456789.12345"));
+ ASSERT_EQUALS("{ \"a\" : { \"$numberDecimal\" : \"123456789.12345\" } }",
+ b.done().jsonString(Strict));
+ }
+};
+
class NumberDoubleNaN {
public:
void run() {
@@ -586,7 +607,8 @@ public:
b.append("r", (int)5);
b.appendTimestamp("s", 123123123123123LL);
b.append("t", 12321312312LL);
- b.appendMaxKey("u");
+ b.append("u", "123456789.12345");
+ b.appendMaxKey("v");
BSONObj o = b.obj();
o.jsonString();
@@ -2695,6 +2717,12 @@ public:
add<JsonStringTests::NumberLongStrict>();
add<JsonStringTests::NumberLongStrictLarge>();
add<JsonStringTests::NumberLongStrictNegative>();
+
+ if (Decimal128::enabled) {
+ add<JsonStringTests::NumberDecimal>();
+ add<JsonStringTests::NumberDecimalStrict>();
+ }
+
add<JsonStringTests::NumberDoubleNaN>();
add<JsonStringTests::NumberDoubleInfinity>();
add<JsonStringTests::NumberDoubleNegativeInfinity>();