diff options
Diffstat (limited to 'jstests/libs')
-rw-r--r-- | jstests/libs/geo_near_random.js | 37 | ||||
-rw-r--r-- | jstests/libs/key1 | 1 | ||||
-rw-r--r-- | jstests/libs/key2 | 1 | ||||
-rw-r--r-- | jstests/libs/testconfig | 4 |
4 files changed, 35 insertions, 8 deletions
diff --git a/jstests/libs/geo_near_random.js b/jstests/libs/geo_near_random.js index 8624ef2..adf4f86 100644 --- a/jstests/libs/geo_near_random.js +++ b/jstests/libs/geo_near_random.js @@ -11,25 +11,46 @@ GeoNearRandomTest = function(name) { } -GeoNearRandomTest.prototype.mkPt = function mkPt(scale){ - scale = scale || 1; // scale is good for staying away from edges - return [((Random.rand() * 359.8) - 179.9) * scale, ((Random.rand() * 180) - 90) * scale]; +GeoNearRandomTest.prototype.mkPt = function mkPt(scale, indexBounds){ + if(!indexBounds){ + scale = scale || 1; // scale is good for staying away from edges + return [((Random.rand() * 359.8) - 179.9) * scale, ((Random.rand() * 180) - 90) * scale]; + } + else{ + var range = indexBounds.max - indexBounds.min; + var eps = Math.pow(2, -40); + // Go very close to the borders but not quite there. + return [( Random.rand() * (range - eps) + eps) + indexBounds.min, ( Random.rand() * (range - eps) + eps ) + indexBounds.min]; + } + } -GeoNearRandomTest.prototype.insertPts = function(nPts) { +GeoNearRandomTest.prototype.insertPts = function(nPts, indexBounds) { assert.eq(this.nPts, 0, "insertPoints already called"); this.nPts = nPts; for (var i=0; i<nPts; i++){ - this.t.insert({_id: i, loc: this.mkPt()}); + this.t.insert({_id: i, loc: this.mkPt(undefined, indexBounds)}); } - - this.t.ensureIndex({loc: '2d'}); + + if(!indexBounds) + this.t.ensureIndex({loc: '2d'}); + else + this.t.ensureIndex({loc: '2d'}, indexBounds) } GeoNearRandomTest.prototype.assertIsPrefix = function(short, long) { for (var i=0; i < short.length; i++){ - assert.eq(short[i], long[i]); + + var xS = short[i].obj ? short[i].obj.loc[0] : short[i].loc[0] + var yS = short[i].obj ? short[i].obj.loc[1] : short[i].loc[1] + var dS = short[i].obj ? short[i].dis : 1 + + var xL = long[i].obj ? long[i].obj.loc[0] : long[i].loc[0] + var yL = long[i].obj ? long[i].obj.loc[1] : long[i].loc[1] + var dL = long[i].obj ? long[i].dis : 1 + + assert.eq([xS, yS, dS], [xL, yL, dL]); } } diff --git a/jstests/libs/key1 b/jstests/libs/key1 new file mode 100644 index 0000000..b5c19e4 --- /dev/null +++ b/jstests/libs/key1 @@ -0,0 +1 @@ +foop de doop diff --git a/jstests/libs/key2 b/jstests/libs/key2 new file mode 100644 index 0000000..cbde821 --- /dev/null +++ b/jstests/libs/key2 @@ -0,0 +1 @@ +other key diff --git a/jstests/libs/testconfig b/jstests/libs/testconfig new file mode 100644 index 0000000..0c1fc87 --- /dev/null +++ b/jstests/libs/testconfig @@ -0,0 +1,4 @@ +fastsync = true +#comment line +#commentedflagwithan = false +version = false |