diff options
author | Ted Tuckman <ted.tuckman@mongodb.com> | 2019-05-08 11:12:49 -0400 |
---|---|---|
committer | Ted Tuckman <ted.tuckman@mongodb.com> | 2019-05-28 17:43:57 -0400 |
commit | 530167637e22f2cff3ddd8551f3229db6ed97824 (patch) | |
tree | 3c42daa85a74c951fd5d63e03cf7ded1cc867827 /src/mongo/db/field_ref_test.cpp | |
parent | fc6edc2f454ae29b1daaa0f2547b8204aa27bf72 (diff) | |
download | mongo-530167637e22f2cff3ddd8551f3229db6ed97824.tar.gz |
SERVER-40826 Add getters to projection nodes
Diffstat (limited to 'src/mongo/db/field_ref_test.cpp')
-rw-r--r-- | src/mongo/db/field_ref_test.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/mongo/db/field_ref_test.cpp b/src/mongo/db/field_ref_test.cpp index f01020cbe0a..9a116ccf98b 100644 --- a/src/mongo/db/field_ref_test.cpp +++ b/src/mongo/db/field_ref_test.cpp @@ -872,5 +872,38 @@ TEST(NumericPathComponents, FieldsWithLeadingZeroesAreNotConsideredNumeric) { ASSERT(numericPathComponents == expectedComponents); } +TEST(RemoveFirstPart, EmptyPathDoesNothing) { + FieldRef path; + path.removeFirstPart(); + ASSERT_EQ(path.numParts(), 0U); +} + +TEST(RemoveFirstPart, PathWithOneComponentBecomesEmpty) { + FieldRef path("first"); + path.removeFirstPart(); + ASSERT_EQ(path.numParts(), 0U); +} + +TEST(RemoveFirstPart, PathWithTwoComponentsOnlyHoldsSecond) { + FieldRef path("remove.keep"); + path.removeFirstPart(); + ASSERT_EQ(path.numParts(), 1U); + ASSERT_EQ(path, FieldRef("keep")); +} + +TEST(RemoveFirstPart, RemovingFirstPartFromLongPathMultipleTimes) { + FieldRef path("first.second.third.fourth.fifth.sixth.seventh.eigth.ninth.tenth"); + path.removeFirstPart(); + ASSERT_EQ(path, FieldRef("second.third.fourth.fifth.sixth.seventh.eigth.ninth.tenth")); + path.removeFirstPart(); + ASSERT_EQ(path, FieldRef("third.fourth.fifth.sixth.seventh.eigth.ninth.tenth")); + path.removeFirstPart(); + ASSERT_EQ(path, FieldRef("fourth.fifth.sixth.seventh.eigth.ninth.tenth")); + path.removeFirstPart(); + ASSERT_EQ(path, FieldRef("fifth.sixth.seventh.eigth.ninth.tenth")); + path.removeFirstPart(); + ASSERT_EQ(path, FieldRef("sixth.seventh.eigth.ninth.tenth")); +} + } // namespace } // namespace mongo |