diff options
| author | Antonin Kral <a.kral@bobek.cz> | 2013-07-17 16:21:49 +0200 |
|---|---|---|
| committer | Antonin Kral <a.kral@bobek.cz> | 2013-07-17 16:21:49 +0200 |
| commit | e3904bf97e74cbbe5dde6b3abc3e797ad7d26b5d (patch) | |
| tree | f2d76fa86bfce0e897a616e02551bdd7d9913682 /src/mongo/base/string_data_test.cpp | |
| parent | bef4346b845150d5318fd7a0acb43554f0d40a06 (diff) | |
Imported Upstream version 2.4.5upstream/2.4.5
Diffstat (limited to 'src/mongo/base/string_data_test.cpp')
| -rw-r--r-- | src/mongo/base/string_data_test.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mongo/base/string_data_test.cpp b/src/mongo/base/string_data_test.cpp index c8ca72ca76c..bbd40011002 100644 --- a/src/mongo/base/string_data_test.cpp +++ b/src/mongo/base/string_data_test.cpp @@ -123,6 +123,22 @@ namespace { ASSERT_EQUALS( string("foo").find( "" ), StringData("foo").find( "" ) ); } + TEST(Rfind, Char1) { + ASSERT_EQUALS( string::npos, StringData( "foo" ).rfind( 'a' ) ); + + ASSERT_EQUALS( 0U, StringData( "foo" ).rfind( 'f' ) ); + ASSERT_EQUALS( 0U, StringData( "foo" ).rfind( 'f', 3 ) ); + ASSERT_EQUALS( 0U, StringData( "foo" ).rfind( 'f', 2 ) ); + ASSERT_EQUALS( 0U, StringData( "foo" ).rfind( 'f', 1 ) ); + ASSERT_EQUALS( string::npos, StringData( "foo", 0 ).rfind( 'f' ) ); + + ASSERT_EQUALS( 2U, StringData( "foo" ).rfind( 'o' ) ); + ASSERT_EQUALS( 2U, StringData( "foo", 3 ).rfind( 'o' ) ); + ASSERT_EQUALS( 1U, StringData( "foo", 2 ).rfind( 'o' ) ); + ASSERT_EQUALS( string::npos, StringData( "foo", 1 ).rfind( 'o' ) ); + ASSERT_EQUALS( string::npos, StringData( "foo", 0 ).rfind( 'o' ) ); + } + // this is to verify we match std::string void SUBSTR_TEST_HELP(StringData big, StringData small, size_t start, size_t len) { ASSERT_EQUALS(small.toString(), big.toString().substr(start, len)); |
