add strcompress function and use it for error output

This commit is contained in:
Axel Kohlmeyer
2025-01-17 22:59:44 -05:00
parent e350f28e26
commit e38c13a764
4 changed files with 75 additions and 12 deletions

View File

@ -50,16 +50,43 @@ TEST(Utils, strsame)
{
std::string text1("some_text");
std::string text2("some_text");
ASSERT_TRUE(utils::strsame(text1,text2));
ASSERT_TRUE(utils::strsame(text1, text2));
text1 = " some _\ttext\n ";
ASSERT_TRUE(utils::strsame(text1,text2));
ASSERT_TRUE(utils::strsame(text1, text2));
text2 = " some _ text\n ";
ASSERT_TRUE(utils::strsame(text1,text2));
ASSERT_TRUE(utils::strsame(text1, text2));
text2 = "some_other_text";
ASSERT_FALSE(utils::strsame(text1,text2));
ASSERT_FALSE(utils::strsame(text1, text2));
text2 = " some other_text";
ASSERT_FALSE(utils::strsame(text1,text2));
ASSERT_FALSE(utils::strsame(text1, text2));
}
TEST(Utils, strcompress)
{
auto compressed = utils::strcompress("\t some text ");
ASSERT_THAT(compressed, StrEq("some text"));
compressed = utils::strcompress("some \ntext");
ASSERT_THAT(compressed, StrEq("some text"));
compressed = utils::strcompress("sometext");
ASSERT_THAT(compressed, StrEq("sometext"));
compressed = utils::strcompress("some text \r\n");
ASSERT_THAT(compressed, StrEq("some text"));
compressed = utils::strcompress("some other text \r\n");
ASSERT_THAT(compressed, StrEq("some other text"));
compressed = utils::strcompress("\v some text \f");
ASSERT_THAT(compressed, StrEq("some text"));
compressed = utils::strcompress(" some\t text ");
ASSERT_THAT(compressed, StrEq("some text"));
compressed = utils::strcompress(" \t\n ");
ASSERT_THAT(compressed, StrEq(""));
}
TEST(Utils, trim)