Merge pull request #1261 from kylef/kylef/strip-resetfg-bg

Strip background colours when we reset foreground
This commit is contained in:
Alexey Sokolov
2016-04-17 18:44:22 +01:00
2 changed files with 27 additions and 1 deletions
+1 -1
View File
@@ -1413,7 +1413,7 @@ CString CString::StripControls_n() const {
digits++;
continue;
}
if (ch == ',' && !comma && digits > 0) {
if (ch == ',' && !comma) {
comma = true;
digits = 0;
continue;
+26
View File
@@ -263,3 +263,29 @@ TEST(StringTest, Contains) {
EXPECT_FALSE(
CString("Hello, I'm Bob").Contains("i'm bob", CString::CaseSensitive));
}
TEST(StringTest, StripControls) {
// Strips reset colours
EXPECT_EQ(CString("\x03test").StripControls(), "test");
// Strips reset foreground and set new background colour
EXPECT_EQ(CString("\x03,03test").StripControls(), "test");
// Strips foreground and background colour
EXPECT_EQ(CString("\x03\x30,03test").StripControls(), "test");
// Strips reset
EXPECT_EQ(CString("\x0Ftest").StripControls(), "test");
// Strips reverse
EXPECT_EQ(CString("\x12test").StripControls(), "test");
// Strips bold
EXPECT_EQ(CString("\x02test").StripControls(), "test");
// Strips italics
EXPECT_EQ(CString("\x16test").StripControls(), "test");
// Strips underline
EXPECT_EQ(CString("\x1Ftest").StripControls(), "test");
}