summaryrefslogtreecommitdiff
path: root/dbtests
diff options
context:
space:
mode:
Diffstat (limited to 'dbtests')
-rw-r--r--dbtests/macrotests.cpp18
-rw-r--r--dbtests/updatetests.cpp45
2 files changed, 49 insertions, 14 deletions
diff --git a/dbtests/macrotests.cpp b/dbtests/macrotests.cpp
index f547c85..36167b0 100644
--- a/dbtests/macrotests.cpp
+++ b/dbtests/macrotests.cpp
@@ -22,26 +22,16 @@
# error malloc defined 0
#endif
-#ifdef assert
-# error assert defined 1
-#endif
-
-#include "../client/parallel.h" //uses assert
-
-#ifdef assert
-# error assert defined 2
-#endif
-
#include "../client/redef_macros.h"
-#ifndef assert
-# error assert not defined 3
+#ifndef malloc
+# error malloc not defined
#endif
#include "../client/undef_macros.h"
-#ifdef assert
-# error assert defined 3
+#ifdef malloc
+# error malloc defined 1
#endif
diff --git a/dbtests/updatetests.cpp b/dbtests/updatetests.cpp
index c912bf4..95476ef 100644
--- a/dbtests/updatetests.cpp
+++ b/dbtests/updatetests.cpp
@@ -519,6 +519,48 @@ namespace UpdateTests {
}
};
+ /** SERVER-4777 */
+ class TwoModsWithinDuplicatedField : public SetBase {
+ public:
+ void run() {
+ client().insert( ns(), BSON( "_id" << 0 << "a" << 1
+ << "x" << BSONObj() << "x" << BSONObj()
+ << "z" << 5 ) );
+ client().update( ns(), BSONObj(), BSON( "$set" << BSON( "x.b" << 1 << "x.c" << 1 ) ) );
+ ASSERT_EQUALS( BSON( "_id" << 0 << "a" << 1
+ << "x" << BSON( "b" << 1 << "c" << 1 ) << "x" << BSONObj()
+ << "z" << 5 ),
+ client().findOne( ns(), BSONObj() ) );
+ }
+ };
+
+ /** SERVER-4777 */
+ class ThreeModsWithinDuplicatedField : public SetBase {
+ public:
+ void run() {
+ client().insert( ns(),
+ BSON( "_id" << 0
+ << "x" << BSONObj() << "x" << BSONObj() << "x" << BSONObj() ) );
+ client().update( ns(), BSONObj(),
+ BSON( "$set" << BSON( "x.b" << 1 << "x.c" << 1 << "x.d" << 1 ) ) );
+ ASSERT_EQUALS( BSON( "_id" << 0
+ << "x" << BSON( "b" << 1 << "c" << 1 << "d" << 1 )
+ << "x" << BSONObj() << "x" << BSONObj() ),
+ client().findOne( ns(), BSONObj() ) );
+ }
+ };
+
+ class TwoModsBeforeExistingField : public SetBase {
+ public:
+ void run() {
+ client().insert( ns(), BSON( "_id" << 0 << "x" << 5 ) );
+ client().update( ns(), BSONObj(),
+ BSON( "$set" << BSON( "a" << 1 << "b" << 1 << "x" << 10 ) ) );
+ ASSERT_EQUALS( BSON( "_id" << 0 << "a" << 1 << "b" << 1 << "x" << 10 ),
+ client().findOne( ns(), BSONObj() ) );
+ }
+ };
+
namespace ModSetTests {
class internal1 {
@@ -854,6 +896,9 @@ namespace UpdateTests {
add< PreserveIdWithIndex >();
add< CheckNoMods >();
add< UpdateMissingToNull >();
+ add< TwoModsWithinDuplicatedField >();
+ add< ThreeModsWithinDuplicatedField >();
+ add< TwoModsBeforeExistingField >();
add< ModSetTests::internal1 >();
add< ModSetTests::inc1 >();