add utility function to compare two string while ignoring whitespace

This commit is contained in:
Axel Kohlmeyer
2025-01-17 14:06:30 -05:00
parent 90416b63fc
commit 9b443c9a4d
4 changed files with 50 additions and 0 deletions

View File

@ -46,6 +46,22 @@ TEST(Utils, strdup)
delete[] copy2;
}
TEST(Utils, strsame)
{
std::string text1("some_text");
std::string text2("some_text");
ASSERT_TRUE(utils::strsame(text1,text2));
text1 = " some _\ttext\n ";
ASSERT_TRUE(utils::strsame(text1,text2));
text2 = " some _ text\n ";
ASSERT_TRUE(utils::strsame(text1,text2));
text2 = "some_other_text";
ASSERT_FALSE(utils::strsame(text1,text2));
text2 = " some other_text";
ASSERT_FALSE(utils::strsame(text1,text2));
}
TEST(Utils, trim)
{
auto trimmed = utils::trim("\t some text");