Add tests for str_clean_whitespaces, fix documentation

This commit is contained in:
Robert Müller 2022-09-28 23:29:55 +02:00
parent 6bc633ed35
commit da57768854
2 changed files with 21 additions and 1 deletions

View file

@ -1302,7 +1302,7 @@ void str_sanitize_filename(char *str);
* *
* @param str String to clean up * @param str String to clean up
* *
* @remark The strings are treated as zero-termineted strings. * @remark The strings are treated as zero-terminated strings.
*/ */
void str_clean_whitespaces(char *str); void str_clean_whitespaces(char *str);

View file

@ -663,6 +663,26 @@ TEST(Str, Sanitize)
EXPECT_STREQ(aBuf, " "); EXPECT_STREQ(aBuf, " ");
} }
TEST(Str, CleanWhitespaces)
{
char aBuf[64];
str_copy(aBuf, "aa bb ccc dddd eeeee");
str_clean_whitespaces(aBuf);
EXPECT_STREQ(aBuf, "aa bb ccc dddd eeeee");
str_copy(aBuf, " ");
str_clean_whitespaces(aBuf);
EXPECT_STREQ(aBuf, "");
str_copy(aBuf, " aa");
str_clean_whitespaces(aBuf);
EXPECT_STREQ(aBuf, "aa");
str_copy(aBuf, "aa ");
str_clean_whitespaces(aBuf);
EXPECT_STREQ(aBuf, "aa");
str_copy(aBuf, " aa bb ccc dddd eeeee ");
str_clean_whitespaces(aBuf);
EXPECT_STREQ(aBuf, "aa bb ccc dddd eeeee");
}
TEST(Str, CompFilename) TEST(Str, CompFilename)
{ {
EXPECT_EQ(str_comp_filenames("a", "a"), 0); EXPECT_EQ(str_comp_filenames("a", "a"), 0);