mirror of https://github.com/google/benchmark.git
Fix StrSplit empty string case (#1142)
This also fixes #1135. Because StrSplit was returning a vector with an empty string, it was treated by PerfCounters::Create as a legitimate ask for setting up a counter with that name. The empty vector is understood by PerfCounters as "just return NoCounters()".
This commit is contained in:
parent
e50b572e89
commit
e0826edea7
|
@ -164,6 +164,7 @@ std::string StrFormat(const char* format, ...) {
|
|||
}
|
||||
|
||||
std::vector<std::string> StrSplit(const std::string& str, char delim) {
|
||||
if (str.empty()) return {};
|
||||
std::vector<std::string> ret;
|
||||
size_t first = 0;
|
||||
size_t next = str.find(delim);
|
||||
|
|
|
@ -151,7 +151,7 @@ TEST(StringUtilTest, stod) {
|
|||
}
|
||||
|
||||
TEST(StringUtilTest, StrSplit) {
|
||||
EXPECT_EQ(benchmark::StrSplit("", ','), std::vector<std::string>{""});
|
||||
EXPECT_EQ(benchmark::StrSplit("", ','), std::vector<std::string>{});
|
||||
EXPECT_EQ(benchmark::StrSplit("hello", ','),
|
||||
std::vector<std::string>({"hello"}));
|
||||
EXPECT_EQ(benchmark::StrSplit("hello,there", ','),
|
||||
|
|
Loading…
Reference in New Issue