From 775a442db99677ca78f4e22c66a12c929aec537b Mon Sep 17 00:00:00 2001 From: MarcUs7i Date: Sat, 11 Jan 2025 00:10:23 +0100 Subject: [PATCH] fix: replace recursive functions with iterative ones in character count and string reversal tests --- test_count_char.c | 8 ++++---- test_reverse_string.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test_count_char.c b/test_count_char.c index 24911cf..1aab24e 100644 --- a/test_count_char.c +++ b/test_count_char.c @@ -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); } \ No newline at end of file diff --git a/test_reverse_string.c b/test_reverse_string.c index 417cfa1..a15cb61 100644 --- a/test_reverse_string.c +++ b/test_reverse_string.c @@ -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); } \ No newline at end of file