Skip to content

Commit

Permalink
Fix some geo polygon tests which weren't testing as much as they mean…
Browse files Browse the repository at this point in the history
…t to.
  • Loading branch information
stbrody committed Aug 30, 2011
1 parent 6b61f6a commit b7a4d0f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 7 additions & 4 deletions jstests/geo_polygon1.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,23 @@ t.save({ loc : [3,-1] }) // Add a point below the center of the bottom
assert.eq( 1 , t.find({loc : { $within : { $polygon : pacman }}} ).count() , "Pacman double point" );

// Make sure we can't add bad polygons
okay = true
try{
t.find( { loc : { $within : { $polygon : [1, 2] } } } ).toArray()
assert( false )
okay = false
}
catch(e){}
assert(okay)
try{
t.find( { loc : { $within : { $polygon : [[1, 2]] } } } ).toArray()
assert( false )
okay = false
}
catch(e){}
assert(okay)
try{
t.find( { loc : { $within : { $polygon : [[1, 2], [2, 3]] } } } ).toArray()
assert( false )
okay = false
}
catch(e){}

assert(okay)

7 changes: 3 additions & 4 deletions jstests/geo_polygon3.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

var numTests = 30;

for( var t = 0; t < numTests; t++ ){
for( var n = 0; n < numTests; n++ ){

t = db.geo_polygon1;
t.drop();
Expand All @@ -17,7 +17,7 @@ for( var t = 0; t < numTests; t++ ){
}
}

t.ensureIndex( { loc : "2d" }, { bits : 2 + t } );
t.ensureIndex( { loc : "2d" }, { bits : 2 + n } );

triangle = [[0,0], [1,1], [0,2]];

Expand Down Expand Up @@ -51,5 +51,4 @@ for( var t = 0; t < numTests; t++ ){
t.save({ loc : [3,-1] }) // Add a point below the center of the bottom

assert.eq( 1 , t.find({loc : { $within : { $polygon : pacman }}} ).count() , "Pacman double point" );

}
}

0 comments on commit b7a4d0f

Please sign in to comment.