summaryrefslogtreecommitdiff
path: root/jstests/geo_box3.js
diff options
context:
space:
mode:
authorRichard Kreuter <richard@10gen.com>2010-05-11 17:12:43 -0400
committerRichard Kreuter <richard@10gen.com>2010-05-11 17:12:43 -0400
commitb0fa349d2eb222af8bd4aee8222128264e79b074 (patch)
tree9fd260c48330712170fdee12dfefea2e70c5ee0c /jstests/geo_box3.js
parente3a72000b03b5d47e00a07e45f89fb4ec6ecb2fe (diff)
downloadmongo-b0fa349d2eb222af8bd4aee8222128264e79b074.tar.gz
Characterize and add tests for the flaw in SERVER-994
Diffstat (limited to 'jstests/geo_box3.js')
-rw-r--r--jstests/geo_box3.js22
1 files changed, 20 insertions, 2 deletions
diff --git a/jstests/geo_box3.js b/jstests/geo_box3.js
index 26b01e72031..c68f522bbf2 100644
--- a/jstests/geo_box3.js
+++ b/jstests/geo_box3.js
@@ -1,7 +1,25 @@
-t=db.geo_box3;
+// How to construct a test to stress the flaw in SERVER-994:
+// construct an index, think up a bounding box inside the index that
+// doesn't include the center of the index, and put a point inside the
+// bounding box.
+// This is the bug reported in SERVER-994, modulo 1000000.
+t=db.geo_box3;
t.drop();
-// SERVER-994
t.insert({ point : { x : -15, y : 10 } });
t.ensureIndex( { point : "2d" } , { min : -21 , max : 21 } );
t.find({point: {"$within": {"$box": [[-20, 7], [0, 15]]} } });
+
+// Two more examples, one where the index is centered at the origin,
+// one not.
+t=db.geo_box3;
+t.drop();
+t.insert({ point : { x : 1.0 , y : 1.0 } });
+t.ensureIndex( { point : "2d" } , { min : -2 , max : 2 } );
+t.find({point: {"$within": {"$box": [[.1, .1], [1.99, 1.99]]} } });
+
+t=db.geo_box3;
+t.drop();
+t.insert({ point : { x : 3.9 , y : 3.9 } });
+t.ensureIndex( { point : "2d" } , { min : 0 , max : 4 } );
+t.find({point: {"$within": {"$box": [[2.05, 2.05], [3.99, 3.99]]} } });