diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 00:22:50 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 10:56:02 -0400 |
commit | 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch) | |
tree | 3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/query/interval_test.cpp | |
parent | 01965cf52bce6976637ecb8f4a622aeb05ab256a (diff) | |
download | mongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz |
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/query/interval_test.cpp')
-rw-r--r-- | src/mongo/db/query/interval_test.cpp | 448 |
1 files changed, 224 insertions, 224 deletions
diff --git a/src/mongo/db/query/interval_test.cpp b/src/mongo/db/query/interval_test.cpp index 62c4b815e53..d9e829a254b 100644 --- a/src/mongo/db/query/interval_test.cpp +++ b/src/mongo/db/query/interval_test.cpp @@ -33,264 +33,264 @@ namespace { - using mongo::BSONObj; - using mongo::Interval; +using mongo::BSONObj; +using mongo::Interval; - // - // Comparison - // +// +// Comparison +// - TEST(Comparison, Equality) { - Interval a(BSON("" << 0 << "" << 10), true, true); - ASSERT_EQUALS(a.compare(a), Interval::INTERVAL_EQUALS); +TEST(Comparison, Equality) { + Interval a(BSON("" << 0 << "" << 10), true, true); + ASSERT_EQUALS(a.compare(a), Interval::INTERVAL_EQUALS); - Interval b(BSON("" << 0 << "" << 10), true, false); - ASSERT_NOT_EQUALS(a.compare(b), Interval::INTERVAL_EQUALS); + Interval b(BSON("" << 0 << "" << 10), true, false); + ASSERT_NOT_EQUALS(a.compare(b), Interval::INTERVAL_EQUALS); - Interval c(BSON("" << 0 << "" << 10), false, true); - ASSERT_NOT_EQUALS(a.compare(c), Interval::INTERVAL_EQUALS); + Interval c(BSON("" << 0 << "" << 10), false, true); + ASSERT_NOT_EQUALS(a.compare(c), Interval::INTERVAL_EQUALS); - Interval d(BSON("" << 0 << "" << 11), true, true); - ASSERT_NOT_EQUALS(a.compare(d), Interval::INTERVAL_EQUALS); + Interval d(BSON("" << 0 << "" << 11), true, true); + ASSERT_NOT_EQUALS(a.compare(d), Interval::INTERVAL_EQUALS); - Interval e(BSON("" << 1 << "" << 10), true, true); - ASSERT_NOT_EQUALS(a.compare(e), Interval::INTERVAL_EQUALS); - } + Interval e(BSON("" << 1 << "" << 10), true, true); + ASSERT_NOT_EQUALS(a.compare(e), Interval::INTERVAL_EQUALS); +} - TEST(Comparison, Contains) { - Interval a(BSON("" << 0 << "" << 10), true, true); - Interval b(BSON("" << 1 << "" << 9), true, true); - ASSERT_EQUALS(a.compare(b), Interval::INTERVAL_CONTAINS); +TEST(Comparison, Contains) { + Interval a(BSON("" << 0 << "" << 10), true, true); + Interval b(BSON("" << 1 << "" << 9), true, true); + ASSERT_EQUALS(a.compare(b), Interval::INTERVAL_CONTAINS); - Interval c(BSON("" << 0 << "" << 10), true, false); - ASSERT_EQUALS(a.compare(c), Interval::INTERVAL_CONTAINS); + Interval c(BSON("" << 0 << "" << 10), true, false); + ASSERT_EQUALS(a.compare(c), Interval::INTERVAL_CONTAINS); - Interval d(BSON("" << 0 << "" << 10), false, true); - ASSERT_EQUALS(a.compare(d), Interval::INTERVAL_CONTAINS); + Interval d(BSON("" << 0 << "" << 10), false, true); + ASSERT_EQUALS(a.compare(d), Interval::INTERVAL_CONTAINS); - Interval e(BSON("" << 0 << "" << 11), false, true); - ASSERT_NOT_EQUALS(a.compare(e), Interval::INTERVAL_CONTAINS); - } + Interval e(BSON("" << 0 << "" << 11), false, true); + ASSERT_NOT_EQUALS(a.compare(e), Interval::INTERVAL_CONTAINS); +} - TEST(Comparison, Within) { - Interval a(BSON("" << 0 << "" << 10), true, true); - ASSERT_NOT_EQUALS(a.compare(a), Interval::INTERVAL_WITHIN); +TEST(Comparison, Within) { + Interval a(BSON("" << 0 << "" << 10), true, true); + ASSERT_NOT_EQUALS(a.compare(a), Interval::INTERVAL_WITHIN); - Interval b(BSON("" << 1 << "" << 9), true, true); - ASSERT_EQUALS(b.compare(a), Interval::INTERVAL_WITHIN); + Interval b(BSON("" << 1 << "" << 9), true, true); + ASSERT_EQUALS(b.compare(a), Interval::INTERVAL_WITHIN); - Interval c(BSON("" << 0 << "" << 10), true, false); - ASSERT_EQUALS(c.compare(a), Interval::INTERVAL_WITHIN); + Interval c(BSON("" << 0 << "" << 10), true, false); + ASSERT_EQUALS(c.compare(a), Interval::INTERVAL_WITHIN); - Interval d(BSON("" << 0 << "" << 10), false, true); - ASSERT_EQUALS(d.compare(a), Interval::INTERVAL_WITHIN); + Interval d(BSON("" << 0 << "" << 10), false, true); + ASSERT_EQUALS(d.compare(a), Interval::INTERVAL_WITHIN); - Interval e(BSON("" << 0 << "" << 11), false, true); - ASSERT_NOT_EQUALS(e.compare(a), Interval::INTERVAL_CONTAINS); - } + Interval e(BSON("" << 0 << "" << 11), false, true); + ASSERT_NOT_EQUALS(e.compare(a), Interval::INTERVAL_CONTAINS); +} - TEST(Comparison, OverlapsBefore) { - Interval a(BSON("" << 1 << "" << 9), true, false); - ASSERT_NOT_EQUALS(a.compare(a), Interval::INTERVAL_OVERLAPS_BEFORE); +TEST(Comparison, OverlapsBefore) { + Interval a(BSON("" << 1 << "" << 9), true, false); + ASSERT_NOT_EQUALS(a.compare(a), Interval::INTERVAL_OVERLAPS_BEFORE); - Interval b(BSON("" << 1 << "" << 9), false, true); - ASSERT_EQUALS(a.compare(b), Interval::INTERVAL_OVERLAPS_BEFORE); + Interval b(BSON("" << 1 << "" << 9), false, true); + ASSERT_EQUALS(a.compare(b), Interval::INTERVAL_OVERLAPS_BEFORE); - Interval c(BSON("" << 1 << "" << 9), false, false); - ASSERT_NOT_EQUALS(a.compare(c), Interval::INTERVAL_OVERLAPS_BEFORE); + Interval c(BSON("" << 1 << "" << 9), false, false); + ASSERT_NOT_EQUALS(a.compare(c), Interval::INTERVAL_OVERLAPS_BEFORE); - Interval d(BSON("" << 2 << "" << 10), true, true); - ASSERT_EQUALS(a.compare(d), Interval::INTERVAL_OVERLAPS_BEFORE); + Interval d(BSON("" << 2 << "" << 10), true, true); + ASSERT_EQUALS(a.compare(d), Interval::INTERVAL_OVERLAPS_BEFORE); - Interval e(BSON("" << 0 << "" << 9), true, false); - ASSERT_NOT_EQUALS(a.compare(e), Interval::INTERVAL_OVERLAPS_BEFORE); + Interval e(BSON("" << 0 << "" << 9), true, false); + ASSERT_NOT_EQUALS(a.compare(e), Interval::INTERVAL_OVERLAPS_BEFORE); - Interval f(BSON("" << 0 << "" << 8), true, false); - ASSERT_NOT_EQUALS(a.compare(f), Interval::INTERVAL_OVERLAPS_BEFORE); - } + Interval f(BSON("" << 0 << "" << 8), true, false); + ASSERT_NOT_EQUALS(a.compare(f), Interval::INTERVAL_OVERLAPS_BEFORE); +} - TEST(Comparison, OverlapsAfter) { - Interval a(BSON("" << 1 << "" << 9), false, true); - ASSERT_NOT_EQUALS(a.compare(a), Interval::INTERVAL_OVERLAPS_AFTER); +TEST(Comparison, OverlapsAfter) { + Interval a(BSON("" << 1 << "" << 9), false, true); + ASSERT_NOT_EQUALS(a.compare(a), Interval::INTERVAL_OVERLAPS_AFTER); - Interval b(BSON("" << 1 << "" << 9), true, false); - ASSERT_EQUALS(a.compare(b), Interval::INTERVAL_OVERLAPS_AFTER); + Interval b(BSON("" << 1 << "" << 9), true, false); + ASSERT_EQUALS(a.compare(b), Interval::INTERVAL_OVERLAPS_AFTER); - Interval c(BSON("" << 1 << "" << 9), true, true); - ASSERT_NOT_EQUALS(a.compare(c), Interval::INTERVAL_OVERLAPS_AFTER); + Interval c(BSON("" << 1 << "" << 9), true, true); + ASSERT_NOT_EQUALS(a.compare(c), Interval::INTERVAL_OVERLAPS_AFTER); - Interval d(BSON("" << 2 << "" << 10), true, true); - ASSERT_NOT_EQUALS(a.compare(d), Interval::INTERVAL_OVERLAPS_AFTER); + Interval d(BSON("" << 2 << "" << 10), true, true); + ASSERT_NOT_EQUALS(a.compare(d), Interval::INTERVAL_OVERLAPS_AFTER); - Interval e(BSON("" << 0 << "" << 9), true, false); - ASSERT_EQUALS(a.compare(e), Interval::INTERVAL_OVERLAPS_AFTER); - } + Interval e(BSON("" << 0 << "" << 9), true, false); + ASSERT_EQUALS(a.compare(e), Interval::INTERVAL_OVERLAPS_AFTER); +} - TEST(Comparison, Precedes) { - Interval a(BSON("" << 10 << "" << 20), true, true); - ASSERT_NOT_EQUALS(a.compare(a), Interval::INTERVAL_PRECEDES); +TEST(Comparison, Precedes) { + Interval a(BSON("" << 10 << "" << 20), true, true); + ASSERT_NOT_EQUALS(a.compare(a), Interval::INTERVAL_PRECEDES); - Interval b(BSON("" << 0 << "" << 10), true, true); - ASSERT_NOT_EQUALS(b.compare(a), Interval::INTERVAL_PRECEDES); + Interval b(BSON("" << 0 << "" << 10), true, true); + ASSERT_NOT_EQUALS(b.compare(a), Interval::INTERVAL_PRECEDES); - Interval c(BSON("" << 0 << "" << 10), true, false); - ASSERT_EQUALS(c.compare(a), Interval::INTERVAL_PRECEDES_COULD_UNION); + Interval c(BSON("" << 0 << "" << 10), true, false); + ASSERT_EQUALS(c.compare(a), Interval::INTERVAL_PRECEDES_COULD_UNION); - Interval d(BSON("" << 0 << "" << 9), true, true); - ASSERT_EQUALS(d.compare(a), Interval::INTERVAL_PRECEDES); + Interval d(BSON("" << 0 << "" << 9), true, true); + ASSERT_EQUALS(d.compare(a), Interval::INTERVAL_PRECEDES); - Interval e(BSON("" << 5 << "" << 15), true, true); - ASSERT_NOT_EQUALS(e.compare(a), Interval::INTERVAL_PRECEDES); + Interval e(BSON("" << 5 << "" << 15), true, true); + ASSERT_NOT_EQUALS(e.compare(a), Interval::INTERVAL_PRECEDES); - Interval f(BSON("" << 5 << "" << 20), true, false); - ASSERT_NOT_EQUALS(f.compare(a), Interval::INTERVAL_PRECEDES); - } + Interval f(BSON("" << 5 << "" << 20), true, false); + ASSERT_NOT_EQUALS(f.compare(a), Interval::INTERVAL_PRECEDES); +} - TEST(Comparison, PrecedesCouldUnion) { - Interval a(BSON("" << 10 << "" << 20), false, true); - ASSERT_NOT_EQUALS(a.compare(a), Interval::INTERVAL_PRECEDES); +TEST(Comparison, PrecedesCouldUnion) { + Interval a(BSON("" << 10 << "" << 20), false, true); + ASSERT_NOT_EQUALS(a.compare(a), Interval::INTERVAL_PRECEDES); - Interval b(BSON("" << 0 << "" << 10), true, false); - ASSERT_EQUALS(b.compare(a), Interval::INTERVAL_PRECEDES); + Interval b(BSON("" << 0 << "" << 10), true, false); + ASSERT_EQUALS(b.compare(a), Interval::INTERVAL_PRECEDES); - Interval c(BSON("" << 0 << "" << 10), true, true); - ASSERT_EQUALS(c.compare(a), Interval::INTERVAL_PRECEDES_COULD_UNION); - } + Interval c(BSON("" << 0 << "" << 10), true, true); + ASSERT_EQUALS(c.compare(a), Interval::INTERVAL_PRECEDES_COULD_UNION); +} - TEST(Comparison, Succeds) { - Interval a(BSON("" << 10 << "" << 20), true, true); - ASSERT_NOT_EQUALS(a.compare(a), Interval::INTERVAL_SUCCEEDS); +TEST(Comparison, Succeds) { + Interval a(BSON("" << 10 << "" << 20), true, true); + ASSERT_NOT_EQUALS(a.compare(a), Interval::INTERVAL_SUCCEEDS); - Interval b(BSON("" << 20 << "" << 30), true, true); - ASSERT_NOT_EQUALS(b.compare(a), Interval::INTERVAL_SUCCEEDS); - - Interval c(BSON("" << 20 << "" << 30), false, true); - ASSERT_EQUALS(c.compare(a), Interval::INTERVAL_SUCCEEDS); - - Interval d(BSON("" << 21 << "" << 30), true, true); - ASSERT_EQUALS(d.compare(a), Interval::INTERVAL_SUCCEEDS); - - Interval e(BSON("" << 15 << "" << 30), true, true); - ASSERT_NOT_EQUALS(e.compare(a), Interval::INTERVAL_SUCCEEDS); - } - - // - // intersection - // - - TEST(Intersection, Equals) { - BSONObj itv = BSON("" << 10 << "" << 20); - Interval a(itv, true, true); - a.intersect(a); - ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); - } - - TEST(Intersection, Contains) { - Interval a(BSON("" << 10 << "" << 20), true, true); - BSONObj itv = BSON("" << 11 << "" << 19); - Interval b(itv, true, true); - a.intersect(b); - ASSERT_EQUALS(a.compare(b), Interval::INTERVAL_EQUALS); - } - - TEST(Intersection, Within) { - BSONObj itv = BSON("" << 10 << "" << 20); - Interval a(itv, true, true); - Interval b(BSON("" << 9 << "" << 21), true, true); - a.intersect(b); - ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); - } - - TEST(Intersection, OverlapsBefore) { - Interval a(BSON("" << 10 << "" << 20), true, true); - Interval b(BSON("" << 15 << "" << 25), true, true); - a.intersect(b); - - BSONObj itv = BSON("" << 15 << "" << 20); - ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); - } - - TEST(Intersection, OverlapsAfter) { - Interval a(BSON("" << 10 << "" << 20), true, true); - Interval b(BSON("" << 5 << "" << 15), true, true); - a.intersect(b); - - BSONObj itv = BSON("" << 10 << "" << 15); - ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); - } - - TEST(Intersection, Procedes) { - Interval a(BSON("" << 10 << "" << 20), true, true); - Interval b(BSON("" << 0 << "" << 5), true, true); - a.intersect(b); - - ASSERT_TRUE(a.isEmpty()); - } - - TEST(Intersection, Succeds) { - Interval a(BSON("" << 10 << "" << 20), true, true); - Interval b(BSON("" << 25 << "" << 30), true, true); - a.intersect(b); - - ASSERT_TRUE(a.isEmpty()); - } - - // - // combine (union) - // - - TEST(Union, Equals) { - BSONObj itv = BSON("" << 10 << "" << 20); - Interval a(itv, true, true); - a.combine(a); - ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); - } - - TEST(Union, Contains) { - BSONObj itv = BSON("" << 10 << "" << 20); - Interval a(itv, true, true); - Interval b(BSON("" << 11 << "" << 19), true, true); - a.combine(b); - ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); - } - - TEST(Union, Within) { - Interval a(BSON("" << 10 << "" << 20), true, true); - Interval b(BSON("" << 9 << "" << 21), true, true); - a.combine(b); - ASSERT_EQUALS(a.compare(b), Interval::INTERVAL_EQUALS); - } - - TEST(Union, OverlapsBefore) { - Interval a(BSON("" << 10 << "" << 20), true, true); - Interval b(BSON("" << 15 << "" << 25), true, true); - a.combine(b); - BSONObj itv = BSON("" << 10 << "" << 25); - ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); - } - - TEST(Union, OverlapsAfter) { - Interval a(BSON("" << 10 << "" << 20), true, true); - Interval b(BSON("" << 5 << "" << 15), true, true); - a.combine(b); - BSONObj itv = BSON("" << 5 << "" << 20); - ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); - } - - TEST(Union, Precedes) { - Interval a(BSON("" << 10 << "" << 20), true, true); - Interval b(BSON("" << 20 << "" << 30), true, true); - a.combine(b); - BSONObj itv = BSON("" << 10 << "" << 30); - ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); - } - - TEST(Union, Succeds) { - Interval a(BSON("" << 10 << "" << 20), true, true); - Interval b(BSON("" << 0 << "" << 5), true, true); - a.combine(b); - BSONObj itv = BSON("" << 0 << "" << 20); - ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); - } - -} // unnamed namespace + Interval b(BSON("" << 20 << "" << 30), true, true); + ASSERT_NOT_EQUALS(b.compare(a), Interval::INTERVAL_SUCCEEDS); + + Interval c(BSON("" << 20 << "" << 30), false, true); + ASSERT_EQUALS(c.compare(a), Interval::INTERVAL_SUCCEEDS); + + Interval d(BSON("" << 21 << "" << 30), true, true); + ASSERT_EQUALS(d.compare(a), Interval::INTERVAL_SUCCEEDS); + + Interval e(BSON("" << 15 << "" << 30), true, true); + ASSERT_NOT_EQUALS(e.compare(a), Interval::INTERVAL_SUCCEEDS); +} + +// +// intersection +// + +TEST(Intersection, Equals) { + BSONObj itv = BSON("" << 10 << "" << 20); + Interval a(itv, true, true); + a.intersect(a); + ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); +} + +TEST(Intersection, Contains) { + Interval a(BSON("" << 10 << "" << 20), true, true); + BSONObj itv = BSON("" << 11 << "" << 19); + Interval b(itv, true, true); + a.intersect(b); + ASSERT_EQUALS(a.compare(b), Interval::INTERVAL_EQUALS); +} + +TEST(Intersection, Within) { + BSONObj itv = BSON("" << 10 << "" << 20); + Interval a(itv, true, true); + Interval b(BSON("" << 9 << "" << 21), true, true); + a.intersect(b); + ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); +} + +TEST(Intersection, OverlapsBefore) { + Interval a(BSON("" << 10 << "" << 20), true, true); + Interval b(BSON("" << 15 << "" << 25), true, true); + a.intersect(b); + + BSONObj itv = BSON("" << 15 << "" << 20); + ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); +} + +TEST(Intersection, OverlapsAfter) { + Interval a(BSON("" << 10 << "" << 20), true, true); + Interval b(BSON("" << 5 << "" << 15), true, true); + a.intersect(b); + + BSONObj itv = BSON("" << 10 << "" << 15); + ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); +} + +TEST(Intersection, Procedes) { + Interval a(BSON("" << 10 << "" << 20), true, true); + Interval b(BSON("" << 0 << "" << 5), true, true); + a.intersect(b); + + ASSERT_TRUE(a.isEmpty()); +} + +TEST(Intersection, Succeds) { + Interval a(BSON("" << 10 << "" << 20), true, true); + Interval b(BSON("" << 25 << "" << 30), true, true); + a.intersect(b); + + ASSERT_TRUE(a.isEmpty()); +} + +// +// combine (union) +// + +TEST(Union, Equals) { + BSONObj itv = BSON("" << 10 << "" << 20); + Interval a(itv, true, true); + a.combine(a); + ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); +} + +TEST(Union, Contains) { + BSONObj itv = BSON("" << 10 << "" << 20); + Interval a(itv, true, true); + Interval b(BSON("" << 11 << "" << 19), true, true); + a.combine(b); + ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); +} + +TEST(Union, Within) { + Interval a(BSON("" << 10 << "" << 20), true, true); + Interval b(BSON("" << 9 << "" << 21), true, true); + a.combine(b); + ASSERT_EQUALS(a.compare(b), Interval::INTERVAL_EQUALS); +} + +TEST(Union, OverlapsBefore) { + Interval a(BSON("" << 10 << "" << 20), true, true); + Interval b(BSON("" << 15 << "" << 25), true, true); + a.combine(b); + BSONObj itv = BSON("" << 10 << "" << 25); + ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); +} + +TEST(Union, OverlapsAfter) { + Interval a(BSON("" << 10 << "" << 20), true, true); + Interval b(BSON("" << 5 << "" << 15), true, true); + a.combine(b); + BSONObj itv = BSON("" << 5 << "" << 20); + ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); +} + +TEST(Union, Precedes) { + Interval a(BSON("" << 10 << "" << 20), true, true); + Interval b(BSON("" << 20 << "" << 30), true, true); + a.combine(b); + BSONObj itv = BSON("" << 10 << "" << 30); + ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); +} + +TEST(Union, Succeds) { + Interval a(BSON("" << 10 << "" << 20), true, true); + Interval b(BSON("" << 0 << "" << 5), true, true); + a.combine(b); + BSONObj itv = BSON("" << 0 << "" << 20); + ASSERT_EQUALS(a.compare(Interval(itv, true, true)), Interval::INTERVAL_EQUALS); +} + +} // unnamed namespace |