File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -821,6 +821,11 @@ namespace mongo {
821821 return *this ;
822822 }
823823
824+ BSONArrayBuilder& appendRegex (const StringData& regex, const StringData& options = " " ) {
825+ _b.appendRegex (num (), regex, options);
826+ return *this ;
827+ }
828+
824829 BSONArrayBuilder& appendTimestamp (unsigned long long ts) {
825830 _b.appendTimestamp (num (), ts);
826831 return *this ;
Original file line number Diff line number Diff line change @@ -1716,17 +1716,25 @@ namespace JsobjTests {
17161716 objb.appendUndefined (objb.numStr (i++));
17171717 arrb.appendUndefined ();
17181718
1719+ objb.appendRegex (objb.numStr (i++), " test" , " imx" );
1720+ arrb.appendRegex (" test" , " imx" );
1721+
1722+ objb.append (objb.numStr (i++), BSONRegEx (" test2" , " s" ));
1723+ arrb.append (BSONRegEx (" test2" , " s" ));
1724+
17191725 BSONObj obj = objb.obj ();
17201726 BSONArray arr = arrb.arr ();
17211727
17221728 ASSERT_EQUALS (obj, arr);
17231729
1724- BSONObj o = BSON ( " obj" << obj << " arr" << arr << " arr2" << BSONArray (obj) );
1730+ BSONObj o = BSON ( " obj" << obj << " arr" << arr << " arr2" << BSONArray (obj)
1731+ << " regex" << BSONRegEx (" reg" , " x" ));
17251732 // keyTest(o);
17261733
17271734 ASSERT_EQUALS (o[" obj" ].type (), Object);
17281735 ASSERT_EQUALS (o[" arr" ].type (), Array);
17291736 ASSERT_EQUALS (o[" arr2" ].type (), Array);
1737+ ASSERT_EQUALS (o[" regex" ].type (), RegEx);
17301738 }
17311739 }; DBTEST_SHIM_TEST(BSONArrayBuilderTest);
17321740
You can’t perform that action at this time.
0 commit comments