summaryrefslogtreecommitdiff
path: root/src/mongo/db/field_ref_test.cpp
diff options
context:
space:
mode:
authorScott Hernandez <scotthernandez@gmail.com>2013-06-12 14:45:43 -0400
committerScott Hernandez <scotthernandez@gmail.com>2013-06-18 11:04:13 -0400
commit800da131d4b2877ec924f6a45dadc8574645211c (patch)
tree5679557693d35fa44f9f4b64d2c34e2fb5ba53bb /src/mongo/db/field_ref_test.cpp
parent5e331a573cfd9a860f5afb1e2bb14cad8394f464 (diff)
downloadmongo-800da131d4b2877ec924f6a45dadc8574645211c.tar.gz
SERVER-7174: new rename mod
Diffstat (limited to 'src/mongo/db/field_ref_test.cpp')
-rw-r--r--src/mongo/db/field_ref_test.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/mongo/db/field_ref_test.cpp b/src/mongo/db/field_ref_test.cpp
index 7dbd7a3359e..007af16c103 100644
--- a/src/mongo/db/field_ref_test.cpp
+++ b/src/mongo/db/field_ref_test.cpp
@@ -139,6 +139,41 @@ namespace {
ASSERT_EQUALS(fieldRef.numReplaced(), 1U);
}
+ TEST(Prefix, Normal) {
+ FieldRef prefix;
+ FieldRef other;
+
+ // Positive case
+ prefix.parse( "a.b" );
+ other.parse( "a.b.c" );
+ ASSERT( prefix.isPrefixOf( other ) );
+ prefix.parse( "a" );
+ ASSERT( prefix.isPrefixOf( other ) );
+ prefix.parse( "a.0" );
+ other.parse( "a.0.c" );
+ ASSERT( prefix.isPrefixOf( other ) );
+
+ // All these tests are for a prefix of "a.b" in other
+ // Negative cases
+ prefix.parse( "a.b" );
+ other.parse( "a.b" );
+ ASSERT( !prefix.isPrefixOf( other ) );
+ other.parse( "a" );
+ ASSERT( !prefix.isPrefixOf( other ) );
+ other.parse( "b" );
+ ASSERT( !prefix.isPrefixOf( other ) );
+ other.parse( "" );
+ ASSERT( !prefix.isPrefixOf( other ) );
+
+ // Change to no prefix, empty string, and other is "" also
+ prefix.parse( "" );
+ ASSERT( !prefix.isPrefixOf( other ) );
+
+ // Change other to "a", leave prefix at ""
+ other.parse( "a" );
+ ASSERT( !prefix.isPrefixOf( other ) );
+ }
+
TEST(Equality, Simple1 ) {
FieldRef a;
a.parse( "a.b" );