Skip to content

Commit

Permalink
fix bug with for loop (#1263)
Browse files Browse the repository at this point in the history
  • Loading branch information
MakarovYaroslav authored and winlinvip committed Nov 11, 2018
1 parent 4cb8de3 commit a2480a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 3 additions & 3 deletions trunk/src/kernel/srs_kernel_utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ string srs_string_trim_end(string str, string trim_chars)
ret.erase(ret.end() - 1);

// ok, matched, should reset the search
i = 0;
i = -1;
}
}

Expand All @@ -240,7 +240,7 @@ string srs_string_trim_start(string str, string trim_chars)
ret.erase(ret.begin());

// ok, matched, should reset the search
i = 0;
i = -1;
}
}

Expand All @@ -259,7 +259,7 @@ string srs_string_remove(string str, string remove_chars)
it = ret.erase(it);

// ok, matched, should reset the search
i = 0;
i = -1;
} else {
++it;
}
Expand Down
11 changes: 10 additions & 1 deletion trunk/src/utest/srs_utest_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1487,14 +1487,23 @@ VOID TEST(KernelUtilityTest, UtilityString)

str1 = srs_string_replace(str, "o", "XX");
EXPECT_STREQ("HellXX, WXXrld! HellXX, SRS!", str1.c_str());

str1 = srs_string_trim_start(str, "x");
EXPECT_STREQ("Hello, World! Hello, SRS!", str1.c_str());

str1 = srs_string_trim_start(str, "S!R");
EXPECT_STREQ("Hello, World! Hello, SRS!", str1.c_str());

str1 = srs_string_trim_start(str, "lHe");
EXPECT_STREQ("o, World! Hello, SRS!", str1.c_str());

str1 = srs_string_trim_end(str, "x");
EXPECT_STREQ("Hello, World! Hello, SRS!", str1.c_str());

str1 = srs_string_trim_end(str, "He");
EXPECT_STREQ("Hello, World! Hello, SRS!", str1.c_str());

str1 = srs_string_trim_end(str, "HeS!R");
str1 = srs_string_trim_end(str, "S!R");
EXPECT_STREQ("Hello, World! Hello, ", str1.c_str());

str1 = srs_string_remove(str, "x");
Expand Down

0 comments on commit a2480a6

Please sign in to comment.