Skip to content

Commit

Permalink
easier debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed May 28, 2012
1 parent 0735336 commit dfcd703
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions jstests/count6.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@ function checkCountForObject( obj ) {
t.ensureIndex( {b:1,a:1} );

function checkCounts( query, expected ) {
assert.eq( expected, t.count( query ) );
assert.eq( expected, t.find( query ).skip( 0 ).limit( 0 ).count( true ) );
assert.eq( expected, t.count( query ) , "A1" );
assert.eq( expected, t.find( query ).skip( 0 ).limit( 0 ).count( true ) , "A2" );
// Check proper counts with various skip and limit specs.
for( var skip = 1; skip <= 2; ++skip ) {
for( var limit = 1; limit <= 2; ++limit ) {
assert.eq( Math.max( expected - skip, 0 ), t.find( query ).skip( skip ).count( true ) );
assert.eq( Math.min( expected, limit ), t.find( query ).limit( limit ).count( true ) );
assert.eq( Math.min( Math.max( expected - skip, 0 ), limit ), t.find( query ).skip( skip ).limit( limit ).count( true ) );
assert.eq( Math.max( expected - skip, 0 ), t.find( query ).skip( skip ).count( true ) , "B1" );
assert.eq( Math.min( expected, limit ), t.find( query ).limit( limit ).count( true ) , "B2" );
assert.eq( Math.min( Math.max( expected - skip, 0 ), limit ), t.find( query ).skip( skip ).limit( limit ).count( true ) , "B4" );

// Check limit(x) = limit(-x)
assert.eq( t.find( query ).limit( limit ).count( true ),
t.find( query ).limit( -limit ).count( true ));
t.find( query ).limit( -limit ).count( true ) , "C1" );
assert.eq( t.find( query ).skip( skip ).limit( limit ).count( true ),
t.find( query ).skip( skip ).limit( -limit ).count( true ));
t.find( query ).skip( skip ).limit( -limit ).count( true ) , "C2" );
}
}

// Check limit(0) has no effect
assert.eq( expected, t.find( query ).limit( 0 ).count( true ));
assert.eq( expected, t.find( query ).limit( 0 ).count( true ) , "D1" );
assert.eq( Math.max( expected - skip, 0 ),
t.find( query ).skip( skip ).limit( 0 ).count( true ));
t.find( query ).skip( skip ).limit( 0 ).count( true ) , "D2" );
assert.eq( expected, t.getDB().runCommand({ count: t.getName(),
query: query, limit: 0 }).n );
query: query, limit: 0 }).n , "D3" );
assert.eq( Math.max( expected - skip, 0 ),
t.getDB().runCommand({ count: t.getName(),
query: query, limit: 0, skip: skip }).n );
query: query, limit: 0, skip: skip }).n , "D4" );
}

for( var i = 0; i < 5; ++i ) {
Expand Down

0 comments on commit dfcd703

Please sign in to comment.