diff options
author | Alberto Lerner <alerner@10gen.com> | 2012-09-21 11:24:15 -0400 |
---|---|---|
committer | Alberto Lerner <alerner@10gen.com> | 2012-09-25 09:40:38 -0400 |
commit | 0e59f675654adbe2ea251dc0e643520508488463 (patch) | |
tree | 381725395fad736f64b626779cc8e6d897bc65b7 /src/mongo/bson/bson_field_test.cpp | |
parent | c470ef7c9c3df63ecf4b06b416292fe0102fe9f2 (diff) | |
download | mongo-0e59f675654adbe2ea251dc0e643520508488463.tar.gz |
Moved BSONField to its own module.
Diffstat (limited to 'src/mongo/bson/bson_field_test.cpp')
-rw-r--r-- | src/mongo/bson/bson_field_test.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/mongo/bson/bson_field_test.cpp b/src/mongo/bson/bson_field_test.cpp new file mode 100644 index 00000000000..2f804666804 --- /dev/null +++ b/src/mongo/bson/bson_field_test.cpp @@ -0,0 +1,45 @@ +/* Copyright 2012 10gen Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mongo/db/jsobj.h" +#include "mongo/unittest/unittest.h" + +namespace { + + using mongo::BSONField; + using mongo::BSONObj; + + TEST(BSONField, Assignment) { + BSONField<int> x("x"); + BSONObj o = BSON(x << 5); + ASSERT_EQUALS(BSON("x" << 5), o); + } + + TEST(BSONField, Make) { + BSONField<int> x("x"); + BSONObj o = BSON(x.make(5)); + ASSERT_EQUALS(BSON("x" << 5), o); + } + + TEST(BSONField, Query) { + BSONField<int> x("x"); + BSONObj o = BSON(x(5)); + ASSERT_EQUALS(BSON("x" << 5), o); + + o = BSON(x.gt(5) ); + ASSERT_EQUALS(BSON("x" << BSON("$gt" << 5)), o); + } + +} // unnamed namespace |