diff options
author | Andy Schwerin <schwerin@mongodb.com> | 2015-06-11 17:19:38 -0400 |
---|---|---|
committer | Andy Schwerin <schwerin@mongodb.com> | 2015-06-12 11:31:18 -0400 |
commit | b8c1e4d6fce108bc8d3b1721a3bc2fd761aff2e1 (patch) | |
tree | 6ce1cc15c76fe7219a15ea378da2922775432967 /src/mongo/util/mongoutils | |
parent | 4718ba3af1dda38f71df5b355a462bcd3c9b564a (diff) | |
download | mongo-b8c1e4d6fce108bc8d3b1721a3bc2fd761aff2e1.tar.gz |
SERVER-9435 Move implementation of str::stripTrailing to site of only caller.
Per SERVER-9435, the function is misleadingly named. It has only one caller, and its
functionality is provided by other standard means, so this patch banishes the implementation
to the near-end-of-life mongoperf.cpp.
Diffstat (limited to 'src/mongo/util/mongoutils')
-rw-r--r-- | src/mongo/util/mongoutils/SConscript | 7 | ||||
-rw-r--r-- | src/mongo/util/mongoutils/str.h | 16 | ||||
-rw-r--r-- | src/mongo/util/mongoutils/str_test.cpp | 81 |
3 files changed, 0 insertions, 104 deletions
diff --git a/src/mongo/util/mongoutils/SConscript b/src/mongo/util/mongoutils/SConscript deleted file mode 100644 index d06f1e56aca..00000000000 --- a/src/mongo/util/mongoutils/SConscript +++ /dev/null @@ -1,7 +0,0 @@ -# -*- mode: python -*- - -Import("env") - -env.CppUnitTest('str_test', - 'str_test.cpp', - LIBDEPS=['$BUILD_DIR/mongo/unittest/unittest']) diff --git a/src/mongo/util/mongoutils/str.h b/src/mongo/util/mongoutils/str.h index e201bc4ac41..ed7fe35411f 100644 --- a/src/mongo/util/mongoutils/str.h +++ b/src/mongo/util/mongoutils/str.h @@ -217,22 +217,6 @@ namespace mongoutils { return p; } - /** remove trailing chars in place */ - inline void stripTrailing(std::string& s, const char *chars) { - std::string::iterator to = s.begin(); - for ( std::string::iterator i = s.begin(); i != s.end(); i++ ) { - // During each iteration if i finds a non-"chars" character it writes it to the - // position of t. So the part of the string left from the "to" iterator is already - // "cleared" string. - if ( !contains(chars, *i) ) { - if ( i != to ) - s.replace(to, to + 1, 1, *i); - to++; - } - } - s.erase(to, s.end()); - } - } // namespace str } // namespace mongoutils diff --git a/src/mongo/util/mongoutils/str_test.cpp b/src/mongo/util/mongoutils/str_test.cpp deleted file mode 100644 index 82564fe1b62..00000000000 --- a/src/mongo/util/mongoutils/str_test.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// str_test.cpp - -/* Copyright 2014 MongoDB, Inc. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License, version 3, -* as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. -* -* As a special exception, the copyright holders give permission to link the -* code of portions of this program with the OpenSSL library under certain -* conditions as described in each individual source file and distribute -* linked combinations including the program with the OpenSSL library. You -* must comply with the GNU Affero General Public License in all respects -* for all of the code used other than as permitted herein. If you modify -* file(s) with this exception, you may extend this exception to your -* version of the file(s), but you are not obligated to do so. If you do not -* wish to do so, delete this exception statement from your version. If you -* delete this exception statement from all source files in the program, -* then also delete it in the license file. -*/ - -#include "mongo/platform/basic.h" - -#include "mongo/unittest/unittest.h" -#include "mongo/util/mongoutils/str.h" - -namespace { - - namespace str = mongoutils::str; - - TEST(StripTrailingTests, RemoveFromHead) { - std::string data("remove from head"); - str::stripTrailing(data, "re"); - ASSERT_EQUALS("mov fom had", data); - } - - TEST(StripTrailingTests, RemoveFromTail) { - std::string data("remove from tail"); - str::stripTrailing(data, "ail"); - ASSERT_EQUALS("remove from t", data); - } - - TEST(StripTrailingTests, RemoveSpaces) { - std::string data("remove spaces"); - str::stripTrailing(data, " a"); - ASSERT_EQUALS("removespces", data); - } - - TEST(StripTrailingTests, RemoveFromMiddle) { - std::string data("remove from middle"); - str::stripTrailing(data, "from"); - ASSERT_EQUALS("eve iddle", data); - } - - TEST(StripTrailingTests, RemoveFromEmpty) { - std::string data(""); - str::stripTrailing(data, "from"); - ASSERT_EQUALS("", data); - } - - TEST(StripTrailingTests, RemoveEmpty) { - std::string data("remove empty"); - str::stripTrailing(data, ""); - ASSERT_EQUALS("remove empty", data); - } - - TEST(StripTrailingTests, RemoveBringsEmptyResult) { - std::string data("remove"); - str::stripTrailing(data, "remove"); - ASSERT_EQUALS("", data); - } - -} // namespace |