summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2012-05-16 10:10:18 -0400
committerEliot Horowitz <eliot@10gen.com>2012-05-16 18:22:19 -0400
commit90aa3acaa7ef9421fc96867734cf5973e4e14b77 (patch)
treeb506a5a1dae73da146c921f7935d0c4386ca2f23 /src/mongo
parented1bc019e56dbbb67bc095a4fc7794fdb1a0f3f8 (diff)
downloadmongo-90aa3acaa7ef9421fc96867734cf5973e4e14b77.tar.gz
fix StringSplitter with splitters of more than 1 character
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/dbtests/basictests.cpp13
-rw-r--r--src/mongo/util/text.cpp2
2 files changed, 14 insertions, 1 deletions
diff --git a/src/mongo/dbtests/basictests.cpp b/src/mongo/dbtests/basictests.cpp
index 773ec210761..9d1ff713875 100644
--- a/src/mongo/dbtests/basictests.cpp
+++ b/src/mongo/dbtests/basictests.cpp
@@ -543,6 +543,19 @@ namespace BasicTests {
test( "a" );
test( "a,b" );
test( "a,b,c" );
+
+ vector<string> x = StringSplitter::split( "axbxc" , "x" );
+ ASSERT_EQUALS( 3 , (int)x.size() );
+ ASSERT_EQUALS( "a" , x[0] );
+ ASSERT_EQUALS( "b" , x[1] );
+ ASSERT_EQUALS( "c" , x[2] );
+
+ x = StringSplitter::split( "axxbxxc" , "xx" );
+ ASSERT_EQUALS( 3 , (int)x.size() );
+ ASSERT_EQUALS( "a" , x[0] );
+ ASSERT_EQUALS( "b" , x[1] );
+ ASSERT_EQUALS( "c" , x[2] );
+
}
};
diff --git a/src/mongo/util/text.cpp b/src/mongo/util/text.cpp
index 9374666a866..de967d37195 100644
--- a/src/mongo/util/text.cpp
+++ b/src/mongo/util/text.cpp
@@ -33,7 +33,7 @@ namespace mongo {
const char * foo = strstr( _big , _splitter );
if ( foo ) {
string s( _big , foo - _big );
- _big = foo + 1;
+ _big = foo + strlen( _splitter );
while ( *_big && strstr( _big , _splitter ) == _big )
_big++;
return s;