Skip to content

Commit

Permalink
Merge pull request #5553 from sepalani/strpopback
Browse files Browse the repository at this point in the history
StringUtil: Add StringPopBackIf UnitTests
  • Loading branch information
shuffle2 committed Jun 6, 2017
2 parents 367fba8 + 5fb26ab commit f018d69
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Source/UnitTests/Common/StringUtilTest.cpp
Expand Up @@ -41,6 +41,40 @@ TEST(StringUtil, StringEndsWith)
EXPECT_TRUE(StringEndsWith("", ""));
}

TEST(StringUtil, StringPopBackIf)
{
std::string abc = "abc";
std::string empty = "";

StringPopBackIf(&abc, 'a');
StringPopBackIf(&empty, 'a');
EXPECT_STREQ("abc", abc.c_str());
EXPECT_STRNE(empty.c_str(), abc.c_str());

StringPopBackIf(&abc, 'c');
StringPopBackIf(&empty, 'c');
EXPECT_STRNE("abc", abc.c_str());
EXPECT_STREQ("ab", abc.c_str());
EXPECT_STRNE(empty.c_str(), abc.c_str());

StringPopBackIf(&abc, 'b');
StringPopBackIf(&empty, 'b');
EXPECT_STRNE("ab", abc.c_str());
EXPECT_STREQ("a", abc.c_str());
EXPECT_STRNE(empty.c_str(), abc.c_str());

StringPopBackIf(&abc, 'a');
StringPopBackIf(&empty, 'a');
EXPECT_STRNE("a", abc.c_str());
EXPECT_STREQ("", abc.c_str());
EXPECT_STREQ(empty.c_str(), abc.c_str());

StringPopBackIf(&abc, 'a');
StringPopBackIf(&empty, 'a');
EXPECT_STREQ("", abc.c_str());
EXPECT_STREQ(empty.c_str(), abc.c_str());
}

TEST(StringUtil, UTF8ToSHIFTJIS)
{
const std::string kirby_unicode =
Expand Down

0 comments on commit f018d69

Please sign in to comment.