summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests/jsobjtests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/dbtests/jsobjtests.cpp')
-rw-r--r--src/mongo/dbtests/jsobjtests.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/mongo/dbtests/jsobjtests.cpp b/src/mongo/dbtests/jsobjtests.cpp
index cce567d04da..aba90c8ae02 100644
--- a/src/mongo/dbtests/jsobjtests.cpp
+++ b/src/mongo/dbtests/jsobjtests.cpp
@@ -2064,6 +2064,27 @@ namespace JsobjTests {
}
};
+ class NestedBuilderOversize {
+ public:
+ void run() {
+ try {
+ BSONObjBuilder outer;
+ BSONObjBuilder inner(outer.subobjStart("inner"));
+
+ string bigStr(1000, 'x');
+ while (true) {
+ ASSERT_LESS_THAN_OR_EQUALS(inner.len(), BufferMaxSize);
+ inner.append("", bigStr);
+ }
+
+ ASSERT(!"Expected Throw");
+ } catch (const DBException& e) {
+ if (e.getCode() != 13548) // we expect the code for oversized buffer
+ throw;
+ }
+ }
+ };
+
class All : public Suite {
public:
All() : Suite( "jsobj" ) {
@@ -2165,6 +2186,7 @@ namespace JsobjTests {
add< BSONForEachTest >();
add< CompareOps >();
add< HashingTest >();
+ add< NestedBuilderOversize >();
}
} myall;