summaryrefslogtreecommitdiff
path: root/dbtests/updatetests.cpp
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-03-24 11:34:09 -0400
committerAaron <aaron@10gen.com>2009-03-24 11:34:09 -0400
commita6c9d60843f2aac9d6704316425dfc3c9622ba5c (patch)
tree790e8e911deb2e72abe1c5aea39796ef15bbe3cc /dbtests/updatetests.cpp
parenta6f3402e0d65a303880b27c7514b8af3343ab2c0 (diff)
downloadmongo-a6c9d60843f2aac9d6704316425dfc3c9622ba5c.tar.gz
embedded mod checkpoint
Diffstat (limited to 'dbtests/updatetests.cpp')
-rw-r--r--dbtests/updatetests.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/dbtests/updatetests.cpp b/dbtests/updatetests.cpp
index 8a1c0e7cd25..2bb3136d026 100644
--- a/dbtests/updatetests.cpp
+++ b/dbtests/updatetests.cpp
@@ -223,6 +223,44 @@ namespace UpdateTests {
}
};
+ class UnorderedNewSet : public SetBase {
+ public:
+ void run() {
+ client().insert( ns(), fromjson( "{'_id':0}" ) );
+ client().update( ns(), BSONObj(), BSON( "$set" << BSON( "f.g.h" << 3.0 << "f.g.a" << 2.0 ) ) );
+ ASSERT( client().findOne( ns(), Query() ).woCompare( fromjson( "{'_id':0,f:{g:{a:2,h:3}}}" ) ) == 0 );
+ }
+ };
+
+ class UnorderedNewSetAdjacent : public SetBase {
+ public:
+ void run() {
+ client().insert( ns(), fromjson( "{'_id':0}" ) );
+ client().update( ns(), BSONObj(), BSON( "$set" << BSON( "f.g.h.b" << 3.0 << "f.g.a.b" << 2.0 ) ) );
+ ASSERT( client().findOne( ns(), Query() ).woCompare( fromjson( "{'_id':0,f:{g:{a:{b:2},h:{b:3}}}}" ) ) == 0 );
+ }
+ };
+
+ class ArrayEmbeddedSet : public SetBase {
+ public:
+ void run() {
+ client().insert( ns(), fromjson( "{'_id':0,z:[4,'b']}" ) );
+ client().update( ns(), BSONObj(), BSON( "$set" << BSON( "z.0" << "a" ) ) );
+ out() << "one: " << client().findOne( ns(), Query() ) << endl;
+ ASSERT( client().findOne( ns(), Query() ).woCompare( fromjson( "{'_id':0,z:[4,'b']}" ) ) == 0 );
+ }
+ };
+
+ class AttemptEmbedInExistingNum : public SetBase {
+ public:
+ void run() {
+ client().insert( ns(), fromjson( "{'_id':0,a:1}" ) );
+ client().update( ns(), BSONObj(), BSON( "$set" << BSON( "a.b" << 1 ) ) );
+ out() << "one: " << client().findOne( ns(), Query() ) << endl;
+ ASSERT( client().findOne( ns(), Query() ).woCompare( fromjson( "{'_id':0,a:1}" ) ) == 0 );
+ }
+ };
+
class All : public UnitTest::Suite {
public:
All() {
@@ -244,6 +282,10 @@ namespace UpdateTests {
add< SetMissingDotted >();
add< SetAdjacentDotted >();
add< IncMissing >();
+ add< UnorderedNewSet >();
+ add< UnorderedNewSetAdjacent >();
+ add< ArrayEmbeddedSet >();
+ add< AttemptEmbedInExistingNum >();
}
};