Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…t to.
  • Loading branch information...
commit b7a4d0ff79a344d1208d9a0115adce9da4399344 1 parent 6b61f6a
Spencer T Brody stbrody authored

Showing 2 changed files with 10 additions and 8 deletions. Show diff stats Hide diff stats

  1. +7 4 jstests/geo_polygon1.js
  2. +3 4 jstests/geo_polygon3.js
11 jstests/geo_polygon1.js
@@ -52,20 +52,23 @@ t.save({ loc : [3,-1] }) // Add a point below the center of the bottom
52 52 assert.eq( 1 , t.find({loc : { $within : { $polygon : pacman }}} ).count() , "Pacman double point" );
53 53
54 54 // Make sure we can't add bad polygons
  55 +okay = true
55 56 try{
56 57 t.find( { loc : { $within : { $polygon : [1, 2] } } } ).toArray()
57   - assert( false )
  58 + okay = false
58 59 }
59 60 catch(e){}
  61 +assert(okay)
60 62 try{
61 63 t.find( { loc : { $within : { $polygon : [[1, 2]] } } } ).toArray()
62   - assert( false )
  64 + okay = false
63 65 }
64 66 catch(e){}
  67 +assert(okay)
65 68 try{
66 69 t.find( { loc : { $within : { $polygon : [[1, 2], [2, 3]] } } } ).toArray()
67   - assert( false )
  70 + okay = false
68 71 }
69 72 catch(e){}
70   -
  73 +assert(okay)
71 74
7 jstests/geo_polygon3.js
@@ -4,7 +4,7 @@
4 4
5 5 var numTests = 30;
6 6
7   -for( var t = 0; t < numTests; t++ ){
  7 +for( var n = 0; n < numTests; n++ ){
8 8
9 9 t = db.geo_polygon1;
10 10 t.drop();
@@ -17,7 +17,7 @@ for( var t = 0; t < numTests; t++ ){
17 17 }
18 18 }
19 19
20   - t.ensureIndex( { loc : "2d" }, { bits : 2 + t } );
  20 + t.ensureIndex( { loc : "2d" }, { bits : 2 + n } );
21 21
22 22 triangle = [[0,0], [1,1], [0,2]];
23 23
@@ -51,5 +51,4 @@ for( var t = 0; t < numTests; t++ ){
51 51 t.save({ loc : [3,-1] }) // Add a point below the center of the bottom
52 52
53 53 assert.eq( 1 , t.find({loc : { $within : { $polygon : pacman }}} ).count() , "Pacman double point" );
54   -
55   -}
  54 +}

0 comments on commit b7a4d0f

Please sign in to comment.
Something went wrong with that request. Please try again.