add utils::strdup() convenience function

This commit is contained in:
Axel Kohlmeyer
2021-02-04 15:35:43 -05:00
parent f5bf10e00f
commit 0f07215a2b
4 changed files with 41 additions and 0 deletions

View File

@ -30,6 +30,21 @@ using ::testing::StrEq;
#define FLERR __FILE__, __LINE__
#endif
TEST(Utils, strdup)
{
std::string original("some_text");
const char *copy = utils::strdup(original);
ASSERT_THAT(original, StrEq(copy));
ASSERT_NE(copy,original.c_str());
const char *copy2 = utils::strdup(copy);
ASSERT_THAT(original, StrEq(copy2));
ASSERT_NE(copy,copy2);
delete[] copy;
delete[] copy2;
}
TEST(Utils, trim)
{
auto trimmed = utils::trim("\t some text");