Initial commit

This commit is contained in:
github-classroom[bot] 2025-01-07 06:46:34 +00:00 committed by GitHub
commit 15c381aaae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 828 additions and 0 deletions

43
test_count_char.c Normal file
View file

@ -0,0 +1,43 @@
/*----------------------------------------------------------
* HTBLA-Leonding
* ---------------------------------------------------------
* Title: Unit tests for 'Count Char'
* Author: S. Schraml
* ----------------------------------------------------------
*/
#include "test_count_char.h"
#include <stdio.h>
#include <string.h>
#include "count_char.h"
TEST(test_count_char_rec) {
char str1[] = "coconut";
int res = count_char_recursive(str1, 'o');
ASSERT_EQUALS(2, res);
res = count_char_recursive(str1, 'a');
ASSERT_EQUALS(0, res);
char str2[] = "Y";
res = count_char_recursive(str2, 'y');
ASSERT_EQUALS(0, res);
char str3[] = "";
res = count_char_recursive(str3, 'z');
ASSERT_EQUALS(0, res);
}
TEST(test_count_char_itr) {
char str1[] = "coconut";
int res = count_char_recursive(str1, 'o');
ASSERT_EQUALS(2, res);
res = count_char_recursive(str1, 'a');
ASSERT_EQUALS(0, res);
char str2[] = "Y";
res = count_char_recursive(str2, 'y');
ASSERT_EQUALS(0, res);
char str3[] = "";
res = count_char_recursive(str3, 'z');
ASSERT_EQUALS(0, res);
}