Skip to content

Commit

Permalink
Test string repetition
Browse files Browse the repository at this point in the history
  • Loading branch information
dr8co committed Jul 12, 2024
1 parent dba5959 commit 3e3189a
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/testModifiers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,3 +728,32 @@ TEST(LiteStringModifiersTest, RightTrimPreservesLeadingSpaces) {
ASSERT_STREQ(string_cstr(s), " \r\n\v hello");
string_free(s);
}

TEST(LiteStringModifiersTest, RepeatStringMultipleTimes) {
lite_string *s = string_new_cstr("abc");
ASSERT_TRUE(string_repeat(s, 3));
ASSERT_STREQ(string_cstr(s), "abcabcabc");
string_free(s);
}

TEST(LiteStringModifiersTest, RepeatEmptyStringReturnsFalse) {
lite_string *s = string_new();
ASSERT_FALSE(string_repeat(s, 3));
string_free(s);
}

TEST(LiteStringModifiersTest, RepeatOnceReturnsFalse) {
lite_string *s = string_new_cstr("abc");
ASSERT_FALSE(string_repeat(s, 1));
string_free(s);
}

TEST(LiteStringModifiersTest, RepeatZeroTimesReturnsFalse) {
lite_string *s = string_new_cstr("abc");
ASSERT_FALSE(string_repeat(s, 0));
string_free(s);
}

TEST(LiteStringModifiersTest, RepeatNullStringReturnsFalse) {
ASSERT_FALSE(string_repeat(nullptr, 3));
}

0 comments on commit 3e3189a

Please sign in to comment.