Skip to content

Commit

Permalink
Tests for SanitizedUTF8()
Browse files Browse the repository at this point in the history
  • Loading branch information
ovalenti committed Sep 23, 2024
1 parent ac30c97 commit 4cb0181
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions collector/test/UtilityTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,25 @@ TEST(ExtractContainerIDFromCgroupTest, TestExtractContainerIDFromCgroup) {
EXPECT_EQ(short_container_id, c.expected_output);
}
}

TEST(SanitizeUTF8Test, TestSanitizeUTF8_Invalid) {
std::string input(
"ab\x80"
"cd");
std::string expected_output("ab?cd");

auto output = SanitizedUTF8(input);

EXPECT_EQ(*output, expected_output);
}

TEST(SanitizeUTF8Test, TestSanitizeUTF8_Valid) {
std::string input("abcd");
std::string expected_output("abcd");

auto output = SanitizedUTF8(input);

EXPECT_FALSE(output);
}

} // namespace collector

0 comments on commit 4cb0181

Please sign in to comment.