From 8cd20d5ebbf21f9dffe82a803157d9dab84423f4 Mon Sep 17 00:00:00 2001 From: Aaron Date: Fri, 27 Mar 2009 13:31:13 -0400 Subject: [PATCH] Add SIZE label --- db/jsobj.cpp | 1 + db/jsobj.h | 1 + dbtests/jsobjtests.cpp | 11 ++++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/db/jsobj.cpp b/db/jsobj.cpp index 6622c040936..b493d361bbc 100644 --- a/db/jsobj.cpp +++ b/db/jsobj.cpp @@ -1174,5 +1174,6 @@ namespace mongo { Labeler::Label LT( "$lt" ); Labeler::Label LTE( "$lte" ); Labeler::Label NE( "$ne" ); + Labeler::Label SIZE( "$size" ); } // namespace mongo diff --git a/db/jsobj.h b/db/jsobj.h index 84ca796cebb..a8f8540777e 100644 --- a/db/jsobj.h +++ b/db/jsobj.h @@ -781,6 +781,7 @@ namespace mongo { extern Labeler::Label LT; extern Labeler::Label LTE; extern Labeler::Label NE; + extern Labeler::Label SIZE; class BSONObjBuilderValueStream : public boost::noncopyable { public: diff --git a/dbtests/jsobjtests.cpp b/dbtests/jsobjtests.cpp index 39b5c18eacd..f004ec23f71 100644 --- a/dbtests/jsobjtests.cpp +++ b/dbtests/jsobjtests.cpp @@ -556,6 +556,15 @@ namespace JsobjTests { } }; + class LabelSize : public LabelBase { + BSONObj expected() { + return BSON( "a" << BSON( "$size" << 4 ) ); + } + BSONObj actual() { + return BSON( "a" << SIZE << 4 ); + } + }; + class LabelMulti : public LabelBase { BSONObj expected() { return BSON( "z" << "q" @@ -591,7 +600,6 @@ namespace JsobjTests { b2.done(); b1.append( "f", 10.0 ); BSONObj ret = b1.done(); - out() << "ret: " << ret << endl; ASSERT( ret.valid() ); ASSERT( ret.woCompare( fromjson( "{a:'bcd',foo:{ggg:44},f:10}" ) ) == 0 ); } @@ -651,6 +659,7 @@ namespace JsobjTests { add< ValueStreamTests::LabelShares >(); add< ValueStreamTests::LabelDouble >(); add< ValueStreamTests::LabelDoubleShares >(); + add< ValueStreamTests::LabelSize >(); add< ValueStreamTests::LabelMulti >(); add< ValueStreamTests::Unallowed >(); add< SubObjectBuilder >();