summaryrefslogtreecommitdiff
path: root/src/mongo/db/matcher/expression_array_test.cpp
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2015-06-10 17:43:13 -0400
committerAndrew Morrow <acm@mongodb.com>2015-06-10 22:37:44 -0400
commita9b6612f5322f916298c19a6728817a1034c6aab (patch)
tree0da5b1ce36e6a8e2d85dbdeb49d505ac99bf6e1d /src/mongo/db/matcher/expression_array_test.cpp
parent0ec1e625760eb9c1a20a3dba78200e8f9ff28d9e (diff)
downloadmongo-a9b6612f5322f916298c19a6728817a1034c6aab.tar.gz
SERVER-17309 Replace std::auto_ptr<T> with std::unique_ptr<T>
Diffstat (limited to 'src/mongo/db/matcher/expression_array_test.cpp')
-rw-r--r--src/mongo/db/matcher/expression_array_test.cpp72
1 files changed, 36 insertions, 36 deletions
diff --git a/src/mongo/db/matcher/expression_array_test.cpp b/src/mongo/db/matcher/expression_array_test.cpp
index 96a89254a34..891d12752f6 100644
--- a/src/mongo/db/matcher/expression_array_test.cpp
+++ b/src/mongo/db/matcher/expression_array_test.cpp
@@ -38,13 +38,13 @@
namespace mongo {
- using std::auto_ptr;
+ using std::unique_ptr;
TEST( ElemMatchObjectMatchExpression, MatchesElementSingle ) {
BSONObj baseOperand = BSON( "b" << 5 );
BSONObj match = BSON( "a" << BSON_ARRAY( BSON( "b" << 5.0 ) ) );
BSONObj notMatch = BSON( "a" << BSON_ARRAY( BSON( "b" << 6 ) ) );
- auto_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() );
ASSERT( eq->init( "b", baseOperand[ "b" ] ).isOK() );
ElemMatchObjectMatchExpression op;
ASSERT( op.init( "a", eq.release() ).isOK() );
@@ -56,7 +56,7 @@ namespace mongo {
BSONObj baseOperand = BSON( "1" << 5 );
BSONObj match = BSON( "a" << BSON_ARRAY( BSON_ARRAY( 's' << 5.0 ) ) );
BSONObj notMatch = BSON( "a" << BSON_ARRAY( BSON_ARRAY( 5 << 6 ) ) );
- auto_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() );
ASSERT( eq->init( "1", baseOperand[ "1" ] ).isOK() );
ElemMatchObjectMatchExpression op;
ASSERT( op.init( "a", eq.release() ).isOK() );
@@ -73,14 +73,14 @@ namespace mongo {
BSONObj notMatch3 = BSON( "a" << BSON_ARRAY( BSON( "b" << BSON_ARRAY( 5 << 6 ) ) ) );
BSONObj match =
BSON( "a" << BSON_ARRAY( BSON( "b" << BSON_ARRAY( 5 << 6 ) << "c" << 7 ) ) );
- auto_ptr<ComparisonMatchExpression> eq1( new EqualityMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> eq1( new EqualityMatchExpression() );
ASSERT( eq1->init( "b", baseOperand1[ "b" ] ).isOK() );
- auto_ptr<ComparisonMatchExpression> eq2( new EqualityMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> eq2( new EqualityMatchExpression() );
ASSERT( eq2->init( "b", baseOperand2[ "b" ] ).isOK() );
- auto_ptr<ComparisonMatchExpression> eq3( new EqualityMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> eq3( new EqualityMatchExpression() );
ASSERT( eq3->init( "c", baseOperand3[ "c" ] ).isOK() );
- auto_ptr<AndMatchExpression> andOp( new AndMatchExpression() );
+ unique_ptr<AndMatchExpression> andOp( new AndMatchExpression() );
andOp->add( eq1.release() );
andOp->add( eq2.release() );
andOp->add( eq3.release() );
@@ -95,7 +95,7 @@ namespace mongo {
TEST( ElemMatchObjectMatchExpression, MatchesNonArray ) {
BSONObj baseOperand = BSON( "b" << 5 );
- auto_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() );
ASSERT( eq->init( "b", baseOperand[ "b" ] ).isOK() );
ElemMatchObjectMatchExpression op;
ASSERT( op.init( "a", eq.release() ).isOK() );
@@ -108,7 +108,7 @@ namespace mongo {
TEST( ElemMatchObjectMatchExpression, MatchesArrayObject ) {
BSONObj baseOperand = BSON( "b" << 5 );
- auto_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() );
ASSERT( eq->init( "b", baseOperand[ "b" ] ).isOK() );
ElemMatchObjectMatchExpression op;
ASSERT( op.init( "a", eq.release() ).isOK() );
@@ -121,7 +121,7 @@ namespace mongo {
TEST( ElemMatchObjectMatchExpression, MatchesMultipleNamedValues ) {
BSONObj baseOperand = BSON( "c" << 5 );
- auto_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() );
ASSERT( eq->init( "c", baseOperand[ "c" ] ).isOK() );
ElemMatchObjectMatchExpression op;
ASSERT( op.init( "a.b", eq.release() ).isOK() );
@@ -142,7 +142,7 @@ namespace mongo {
TEST( ElemMatchObjectMatchExpression, ElemMatchKey ) {
BSONObj baseOperand = BSON( "c" << 6 );
- auto_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> eq( new EqualityMatchExpression() );
ASSERT( eq->init( "c", baseOperand[ "c" ] ).isOK() );
ElemMatchObjectMatchExpression op;
ASSERT( op.init( "a.b", eq.release() ).isOK() );
@@ -172,7 +172,7 @@ namespace mongo {
/**
TEST( ElemMatchObjectMatchExpression, MatchesIndexKey ) {
BSONObj baseOperand = BSON( "b" << 5 );
- auto_ptr<ComparisonMatchExpression> eq( new ComparisonMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> eq( new ComparisonMatchExpression() );
ASSERT( eq->init( "b", baseOperand[ "b" ] ).isOK() );
ElemMatchObjectMatchExpression op;
ASSERT( op.init( "a", eq.release() ).isOK() );
@@ -187,7 +187,7 @@ namespace mongo {
BSONObj baseOperand = BSON( "$gt" << 5 );
BSONObj match = BSON( "a" << BSON_ARRAY( 6 ) );
BSONObj notMatch = BSON( "a" << BSON_ARRAY( 4 ) );
- auto_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() );
ASSERT( gt->init( "", baseOperand[ "$gt" ] ).isOK() );
ElemMatchValueMatchExpression op;
ASSERT( op.init( "a", gt.release() ).isOK() );
@@ -201,9 +201,9 @@ namespace mongo {
BSONObj notMatch1 = BSON( "a" << BSON_ARRAY( 0 << 1 ) );
BSONObj notMatch2 = BSON( "a" << BSON_ARRAY( 10 << 11 ) );
BSONObj match = BSON( "a" << BSON_ARRAY( 0 << 5 << 11 ) );
- auto_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() );
ASSERT( gt->init( "", baseOperand1[ "$gt" ] ).isOK() );
- auto_ptr<ComparisonMatchExpression> lt( new LTMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> lt( new LTMatchExpression() );
ASSERT( lt->init( "", baseOperand2[ "$lt" ] ).isOK() );
ElemMatchValueMatchExpression op;
@@ -218,7 +218,7 @@ namespace mongo {
TEST( ElemMatchValueMatchExpression, MatchesNonArray ) {
BSONObj baseOperand = BSON( "$gt" << 5 );
- auto_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() );
ASSERT( gt->init( "", baseOperand[ "$gt" ] ).isOK() );
ElemMatchObjectMatchExpression op;
ASSERT( op.init( "a", gt.release() ).isOK() );
@@ -230,7 +230,7 @@ namespace mongo {
TEST( ElemMatchValueMatchExpression, MatchesArrayScalar ) {
BSONObj baseOperand = BSON( "$gt" << 5 );
- auto_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() );
ASSERT( gt->init( "", baseOperand[ "$gt" ] ).isOK() );
ElemMatchValueMatchExpression op;
ASSERT( op.init( "a", gt.release() ).isOK() );
@@ -241,7 +241,7 @@ namespace mongo {
TEST( ElemMatchValueMatchExpression, MatchesMultipleNamedValues ) {
BSONObj baseOperand = BSON( "$gt" << 5 );
- auto_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() );
ASSERT( gt->init( "", baseOperand[ "$gt" ] ).isOK() );
ElemMatchValueMatchExpression op;
ASSERT( op.init( "a.b", gt.release() ).isOK() );
@@ -254,7 +254,7 @@ namespace mongo {
TEST( ElemMatchValueMatchExpression, ElemMatchKey ) {
BSONObj baseOperand = BSON( "$gt" << 6 );
- auto_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> gt( new GTMatchExpression() );
ASSERT( gt->init( "", baseOperand[ "$gt" ] ).isOK() );
ElemMatchValueMatchExpression op;
ASSERT( op.init( "a.b", gt.release() ).isOK() );
@@ -282,7 +282,7 @@ namespace mongo {
/**
TEST( ElemMatchValueMatchExpression, MatchesIndexKey ) {
BSONObj baseOperand = BSON( "$lt" << 5 );
- auto_ptr<LtOp> lt( new ComparisonMatchExpression() );
+ unique_ptr<LtOp> lt( new ComparisonMatchExpression() );
ASSERT( lt->init( "a", baseOperand[ "$lt" ] ).isOK() );
ElemMatchValueMatchExpression op;
ASSERT( op.init( "a", lt.release() ).isOK() );
@@ -297,40 +297,40 @@ namespace mongo {
BSONObj baseOperanda1 = BSON( "a" << 1 );
- auto_ptr<ComparisonMatchExpression> eqa1( new EqualityMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> eqa1( new EqualityMatchExpression() );
ASSERT( eqa1->init( "a", baseOperanda1[ "a" ] ).isOK() );
BSONObj baseOperandb1 = BSON( "b" << 1 );
- auto_ptr<ComparisonMatchExpression> eqb1( new EqualityMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> eqb1( new EqualityMatchExpression() );
ASSERT( eqb1->init( "b", baseOperandb1[ "b" ] ).isOK() );
- auto_ptr<AndMatchExpression> and1( new AndMatchExpression() );
+ unique_ptr<AndMatchExpression> and1( new AndMatchExpression() );
and1->add( eqa1.release() );
and1->add( eqb1.release() );
// and1 = { a : 1, b : 1 }
- auto_ptr<ElemMatchObjectMatchExpression> elemMatch1( new ElemMatchObjectMatchExpression() );
+ unique_ptr<ElemMatchObjectMatchExpression> elemMatch1( new ElemMatchObjectMatchExpression() );
elemMatch1->init( "x", and1.release() );
// elemMatch1 = { x : { $elemMatch : { a : 1, b : 1 } } }
BSONObj baseOperanda2 = BSON( "a" << 2 );
- auto_ptr<ComparisonMatchExpression> eqa2( new EqualityMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> eqa2( new EqualityMatchExpression() );
ASSERT( eqa2->init( "a", baseOperanda2[ "a" ] ).isOK() );
BSONObj baseOperandb2 = BSON( "b" << 2 );
- auto_ptr<ComparisonMatchExpression> eqb2( new EqualityMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> eqb2( new EqualityMatchExpression() );
ASSERT( eqb2->init( "b", baseOperandb2[ "b" ] ).isOK() );
- auto_ptr<AndMatchExpression> and2( new AndMatchExpression() );
+ unique_ptr<AndMatchExpression> and2( new AndMatchExpression() );
and2->add( eqa2.release() );
and2->add( eqb2.release() );
// and2 = { a : 2, b : 2 }
- auto_ptr<ElemMatchObjectMatchExpression> elemMatch2( new ElemMatchObjectMatchExpression() );
+ unique_ptr<ElemMatchObjectMatchExpression> elemMatch2( new ElemMatchObjectMatchExpression() );
elemMatch2->init( "x", and2.release() );
// elemMatch2 = { x : { $elemMatch : { a : 2, b : 2 } } }
- auto_ptr<AndMatchExpression> andOfEM( new AndMatchExpression() );
+ unique_ptr<AndMatchExpression> andOfEM( new AndMatchExpression() );
andOfEM->add( elemMatch1.release() );
andOfEM->add( elemMatch2.release() );
@@ -354,34 +354,34 @@ namespace mongo {
TEST( AndOfElemMatch, Matches ) {
BSONObj baseOperandgt1 = BSON( "$gt" << 1 );
- auto_ptr<ComparisonMatchExpression> gt1( new GTMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> gt1( new GTMatchExpression() );
ASSERT( gt1->init( "", baseOperandgt1[ "$gt" ] ).isOK() );
BSONObj baseOperandlt1 = BSON( "$lt" << 10 );
- auto_ptr<ComparisonMatchExpression> lt1( new LTMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> lt1( new LTMatchExpression() );
ASSERT( lt1->init( "", baseOperandlt1[ "$lt" ] ).isOK() );
- auto_ptr<ElemMatchValueMatchExpression> elemMatch1( new ElemMatchValueMatchExpression() );
+ unique_ptr<ElemMatchValueMatchExpression> elemMatch1( new ElemMatchValueMatchExpression() );
elemMatch1->init( "x" );
elemMatch1->add( gt1.release() );
elemMatch1->add( lt1.release() );
// elemMatch1 = { x : { $elemMatch : { $gt : 1 , $lt : 10 } } }
BSONObj baseOperandgt2 = BSON( "$gt" << 101 );
- auto_ptr<ComparisonMatchExpression> gt2( new GTMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> gt2( new GTMatchExpression() );
ASSERT( gt2->init( "", baseOperandgt2[ "$gt" ] ).isOK() );
BSONObj baseOperandlt2 = BSON( "$lt" << 110 );
- auto_ptr<ComparisonMatchExpression> lt2( new LTMatchExpression() );
+ unique_ptr<ComparisonMatchExpression> lt2( new LTMatchExpression() );
ASSERT( lt2->init( "", baseOperandlt2[ "$lt" ] ).isOK() );
- auto_ptr<ElemMatchValueMatchExpression> elemMatch2( new ElemMatchValueMatchExpression() );
+ unique_ptr<ElemMatchValueMatchExpression> elemMatch2( new ElemMatchValueMatchExpression() );
elemMatch2->init( "x" );
elemMatch2->add( gt2.release() );
elemMatch2->add( lt2.release() );
// elemMatch2 = { x : { $elemMatch : { $gt : 101 , $lt : 110 } } }
- auto_ptr<AndMatchExpression> andOfEM( new AndMatchExpression() );
+ unique_ptr<AndMatchExpression> andOfEM( new AndMatchExpression() );
andOfEM->add( elemMatch1.release() );
andOfEM->add( elemMatch2.release() );