summaryrefslogtreecommitdiff
path: root/src/mongo/db/namespace_string_test.cpp
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@10gen.com>2013-09-20 18:41:21 -0400
committerSpencer T Brody <spencer@10gen.com>2013-09-23 17:18:39 -0400
commit19140c53ad460ebf741de9c48b224f2443cdb18e (patch)
treea5017e1b8b2689a051b21ef0e17d267a235462d8 /src/mongo/db/namespace_string_test.cpp
parent69a0994c38b2ff5919325f4bc7af6c9802c6eaac (diff)
downloadmongo-19140c53ad460ebf741de9c48b224f2443cdb18e.tar.gz
Introduce NamespaceString::validCollectionName that actually takes a collection name
Diffstat (limited to 'src/mongo/db/namespace_string_test.cpp')
-rw-r--r--src/mongo/db/namespace_string_test.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/mongo/db/namespace_string_test.cpp b/src/mongo/db/namespace_string_test.cpp
index f361018e541..74a65b6d70a 100644
--- a/src/mongo/db/namespace_string_test.cpp
+++ b/src/mongo/db/namespace_string_test.cpp
@@ -73,11 +73,21 @@ namespace mongo {
ASSERT( NamespaceString::normal( "local.oplog.$main" ) );
}
+ TEST( NamespaceStringTest, CollectionComponentValidNames ) {
+ ASSERT( NamespaceString::validCollectionComponent( "a.b" ) );
+ ASSERT( NamespaceString::validCollectionComponent( "a.b" ) );
+ ASSERT( !NamespaceString::validCollectionComponent( "a." ) );
+ ASSERT( NamespaceString::validCollectionComponent( "a.b." ) ); // TODO: should this change?
+ }
+
TEST( NamespaceStringTest, CollectionValidNames ) {
+ ASSERT( NamespaceString::validCollectionName( "a" ) );
ASSERT( NamespaceString::validCollectionName( "a.b" ) );
- ASSERT( NamespaceString::validCollectionName( "a.b" ) );
- ASSERT( !NamespaceString::validCollectionName( "a." ) );
+ ASSERT( NamespaceString::validCollectionName( "a." ) ); // TODO: should this change?
ASSERT( NamespaceString::validCollectionName( "a.b." ) ); // TODO: should this change?
+ ASSERT( !NamespaceString::validCollectionName( "$a" ) );
+ ASSERT( !NamespaceString::validCollectionName( "a$b" ) );
+ ASSERT( !NamespaceString::validCollectionName( "" ) );
}
TEST( NamespaceStringTest, DBHash ) {