summaryrefslogtreecommitdiff
path: root/jstests/numberlong2.js
diff options
context:
space:
mode:
authorSiyuan Zhou <siyuan.zhou@mongodb.com>2014-03-03 17:15:39 -0500
committerMatt Kangas <matt.kangas@mongodb.com>2014-03-03 22:54:14 -0500
commit93d8befdbac74fb965faa4d3a8ae3e60d5a7a5b9 (patch)
treeb1be042b0d074266fb417177b33aa0f266a3f38b /jstests/numberlong2.js
parent3660343e0b4627d2fee4afb89b74d32644d16d18 (diff)
downloadmongo-93d8befdbac74fb965faa4d3a8ae3e60d5a7a5b9.tar.gz
SERVER-12127 Temporarily put back jstest in order not to lose test coverage.
Signed-off-by: Matt Kangas <matt.kangas@mongodb.com>
Diffstat (limited to 'jstests/numberlong2.js')
-rw-r--r--jstests/numberlong2.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/jstests/numberlong2.js b/jstests/numberlong2.js
new file mode 100644
index 00000000000..5d7529a9e21
--- /dev/null
+++ b/jstests/numberlong2.js
@@ -0,0 +1,28 @@
+// Test precision of NumberLong values with v1 index code SERVER-3717
+
+t = db.jstests_numberlong2;
+t.drop();
+
+t.ensureIndex( {x:1} );
+
+function chk(longNum) {
+ t.remove({});
+ t.save({ x: longNum });
+ assert.eq(longNum, t.find().hint({ x: 1 }).next().x);
+ assert.eq(longNum, t.find({}, { _id: 0, x: 1 }).hint({ x: 1 }).next().x);
+}
+
+chk( NumberLong("1123539983311657217") );
+chk(NumberLong("-1123539983311657217"));
+ chk(NumberLong("4503599627370495"));
+ chk(NumberLong("4503599627370496"));
+ chk(NumberLong("4503599627370497"));
+
+t.remove({});
+
+s = "11235399833116571";
+for( i = 99; i >= 0; --i ) {
+ t.save( {x:NumberLong( s + i )} );
+}
+
+assert.eq( t.find().sort( {x:1} ).hint( {$natural:1} ).toArray(), t.find().sort( {x:1} ).hint( {x:1} ).toArray() );