Skip to content
Browse files

Fix some geo polygon tests which weren't testing as much as they mean…

…t to.
  • Loading branch information...
1 parent 6b61f6a commit b7a4d0ff79a344d1208d9a0115adce9da4399344 @stbrody stbrody committed Aug 30, 2011
Showing with 10 additions and 8 deletions.
  1. +7 −4 jstests/geo_polygon1.js
  2. +3 −4 jstests/geo_polygon3.js
View
11 jstests/geo_polygon1.js
@@ -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)
View
7 jstests/geo_polygon3.js
@@ -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();
@@ -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]];
@@ -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.
Something went wrong with that request. Please try again.