Initial commit
This commit is contained in:
commit
15c381aaae
19 changed files with 828 additions and 0 deletions
43
test_count_char.c
Normal file
43
test_count_char.c
Normal 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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue