diff options
author | Qingyang Chen <qingyang.chen@10gen.com> | 2015-07-02 17:39:24 -0400 |
---|---|---|
committer | Qingyang Chen <qingyang.chen@10gen.com> | 2015-07-13 16:47:01 -0400 |
commit | 908313432e597623361df39339cee452176fd7b2 (patch) | |
tree | 58416f303d0b1fc2d1c21c41d9b7012b784432db /src/mongo/db/query/index_bounds_builder_test.cpp | |
parent | 95428be95d52697c04908b279a7efef8f4e41ec8 (diff) | |
download | mongo-908313432e597623361df39339cee452176fd7b2.tar.gz |
SERVER-19243 $type to support "number"
Diffstat (limited to 'src/mongo/db/query/index_bounds_builder_test.cpp')
-rw-r--r-- | src/mongo/db/query/index_bounds_builder_test.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/mongo/db/query/index_bounds_builder_test.cpp b/src/mongo/db/query/index_bounds_builder_test.cpp index 90a509a2577..bd8b9d0d97e 100644 --- a/src/mongo/db/query/index_bounds_builder_test.cpp +++ b/src/mongo/db/query/index_bounds_builder_test.cpp @@ -622,6 +622,33 @@ TEST(IndexBoundsBuilderTest, TranslateGteBinData) { } // +// $type +// + +TEST(IndexBoundsBuilderTest, TypeNumber) { + IndexEntry testIndex = IndexEntry(BSONObj()); + BSONObj obj = fromjson("{a: {$type: 'number'}}"); + unique_ptr<MatchExpression> expr(parseMatchExpression(obj)); + BSONElement elt = obj.firstElement(); + OrderedIntervalList oil; + IndexBoundsBuilder::BoundsTightness tightness; + IndexBoundsBuilder::translate(expr.get(), elt, testIndex, &oil, &tightness); + ASSERT_EQUALS(oil.name, "a"); + ASSERT_EQUALS(oil.intervals.size(), 1U); + + // Build the expected interval. + BSONObjBuilder bob; + BSONType type = BSONType::NumberInt; + bob.appendMinForType("", type); + bob.appendMaxForType("", type); + BSONObj expectedInterval = bob.obj(); + + ASSERT_EQUALS(Interval::INTERVAL_EQUALS, + oil.intervals[0].compare(Interval(expectedInterval, true, true))); + ASSERT_EQUALS(tightness, IndexBoundsBuilder::EXACT); +} + +// // $exists tests // |