fix: replace recursive functions with iterative ones in character count and string reversal tests
This commit is contained in:
parent
6cecc84d30
commit
775a442db9
2 changed files with 7 additions and 7 deletions
|
|
@ -30,14 +30,14 @@ TEST(test_count_char_rec) {
|
|||
|
||||
TEST(test_count_char_itr) {
|
||||
char str1[] = "coconut";
|
||||
int res = count_char_recursive(str1, 'o');
|
||||
int res = count_char_iterative(str1, 'o');
|
||||
ASSERT_EQUALS(2, res);
|
||||
res = count_char_recursive(str1, 'a');
|
||||
res = count_char_iterative(str1, 'a');
|
||||
ASSERT_EQUALS(0, res);
|
||||
char str2[] = "Y";
|
||||
res = count_char_recursive(str2, 'y');
|
||||
res = count_char_iterative(str2, 'y');
|
||||
ASSERT_EQUALS(0, res);
|
||||
char str3[] = "";
|
||||
res = count_char_recursive(str3, 'z');
|
||||
res = count_char_iterative(str3, 'z');
|
||||
ASSERT_EQUALS(0, res);
|
||||
}
|
||||
|
|
@ -28,12 +28,12 @@ TEST(test_reverse_string_rec) {
|
|||
|
||||
TEST(test_reverse_string_itr) {
|
||||
char str1[] = "testing";
|
||||
reverse_string_recursive(str1, 0, strlen(str1) - 1);
|
||||
reverse_string_iterative(str1, 0, strlen(str1) - 1);
|
||||
ASSERT_EQUALS_STR("gnitset", str1);
|
||||
char str2[] = "X";
|
||||
reverse_string_recursive(str2, 0, strlen(str2) - 1);
|
||||
reverse_string_iterative(str2, 0, strlen(str2) - 1);
|
||||
ASSERT_EQUALS_STR("X", str2);
|
||||
char str3[] = "";
|
||||
reverse_string_recursive(str3, 0, strlen(str3) - 1);
|
||||
reverse_string_iterative(str3, 0, strlen(str3) - 1);
|
||||
ASSERT_EQUALS_STR("", str3);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue