summaryrefslogtreecommitdiff
path: root/dbtests/updatetests.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-12-21 15:56:56 -0500
committerEliot Horowitz <eliot@10gen.com>2009-12-21 15:56:56 -0500
commitc32fbf2b0f4c8a87306d32bb9cb8c17860d5225b (patch)
treec98eb3287f19063ba2c1fe2123d343a217d53305 /dbtests/updatetests.cpp
parent1efd9ea3b47b50252da4a2ea6c00bf70a6727ea1 (diff)
downloadmongo-c32fbf2b0f4c8a87306d32bb9cb8c17860d5225b.tar.gz
some update c++ unit tests
Diffstat (limited to 'dbtests/updatetests.cpp')
-rw-r--r--dbtests/updatetests.cpp45
1 files changed, 44 insertions, 1 deletions
diff --git a/dbtests/updatetests.cpp b/dbtests/updatetests.cpp
index 17d202ee585..b673f5f322a 100644
--- a/dbtests/updatetests.cpp
+++ b/dbtests/updatetests.cpp
@@ -601,6 +601,47 @@ namespace UpdateTests {
};
};
+
+ namespace basic {
+ class Base : public ClientBase {
+ virtual BSONObj initial() = 0;
+ virtual BSONObj mod() = 0;
+ virtual BSONObj after() = 0;
+ virtual const char * ns() = 0;
+
+ public:
+
+ Base(){}
+ virtual ~Base(){}
+
+ void run(){
+ client().dropCollection( ns() );
+
+ client().insert( ns() , initial() );
+ client().update( ns() , BSONObj() , mod() );
+ ASSERT_EQUALS( after() , client().findOne( ns(), BSONObj() ));
+
+ client().dropCollection( ns() );
+ }
+ };
+
+ class inc1 : public Base {
+ virtual BSONObj initial(){
+ return BSON( "_id" << 1 << "x" << 1 );
+ }
+ virtual BSONObj mod(){
+ return BSON( "$inc" << BSON( "x" << 2 ) );
+ }
+ virtual BSONObj after(){
+ return BSON( "_id" << 1 << "x" << 3 );
+ }
+ virtual const char * ns(){
+ return "unittests.inc1";
+ }
+
+ };
+
+ };
class All : public Suite {
public:
@@ -655,12 +696,14 @@ namespace UpdateTests {
add< PreserveIdWithIndex >();
add< CheckNoMods >();
add< UpdateMissingToNull >();
-
+
add< ModSetTests::internal1 >();
add< ModSetTests::inc1 >();
add< ModSetTests::inc2 >();
add< ModSetTests::set1 >();
add< ModSetTests::push1 >();
+
+ add< basic::inc1 >();
}
} myall;