Lennart Goetze
11 months ago
24 changed files with 817 additions and 4 deletions
-
2build/test/cache/defines_dependency.yml
-
223build/test/cache/test_WortSpiel.c
-
1build/test/dependencies/WortSpiel.d
-
4build/test/dependencies/test_WortSpiel.d
-
4build/test/dependencies/test_WortSpiel_runner.d
-
BINbuild/test/out/c/WortSpiel.o
-
BINbuild/test/out/c/test_WortSpiel.o
-
BINbuild/test/out/c/test_WortSpiel_runner.o
-
BINbuild/test/out/test_SchereSteinPapier.out
-
BINbuild/test/out/test_WortSpiel.out
-
BINbuild/test/out/test_ageinseconds.out
-
BINbuild/test/out/test_minirechner.out
-
BINbuild/test/out/test_zahlenraten.out
-
223build/test/preprocess/files/test_WortSpiel.c
-
3build/test/preprocess/includes/test_WortSpiel.c
-
2build/test/results/test_SchereSteinPapier.pass
-
62build/test/results/test_WortSpiel.pass
-
2build/test/results/test_ageinseconds.pass
-
2build/test/results/test_minirechner.pass
-
2build/test/results/test_zahlenraten.pass
-
103build/test/runners/test_WortSpiel_runner.c
-
86src/WortSpiel.c
-
9src/WortSpiel.h
-
93test/test_WortSpiel.c
@ -0,0 +1,223 @@ |
|||||
|
#include "src/WortSpiel.h" |
||||
|
#include "C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
void setUp(void) |
||||
|
|
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void tearDown(void) |
||||
|
|
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testLoescheBuchstaben_Buchstabeexistiert(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
char wort1[] = "Beispiel"; |
||||
|
|
||||
|
loescheBuchstaben(wort1, 'i'); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Bespel")), (const char*)((wort1)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(19)); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testLoescheBuchstaben_Buchstabeexistiertnicht(void) { |
||||
|
|
||||
|
char wort2[] = "Test"; |
||||
|
|
||||
|
loescheBuchstaben(wort2, 'z'); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Test")), (const char*)((wort2)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(25)); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testLoescheBuchstaben_Leereswort(void) { |
||||
|
|
||||
|
char wort3[] = ""; |
||||
|
|
||||
|
loescheBuchstaben(wort3, 'a'); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("")), (const char*)((wort3)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(31)); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testZaehleBuchstaben_Buchstabenexistiert(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
char wort1[] = "Beispiel"; |
||||
|
|
||||
|
int anzahl1 = zaehleBuchstaben(wort1, 'i'); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((anzahl1)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(38), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testZaehleBuchstaben_Buchstabenexistiertnicht(void) { |
||||
|
|
||||
|
char wort2[] = "Test"; |
||||
|
|
||||
|
int anzahl2 = zaehleBuchstaben(wort2, 'z'); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((anzahl2)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(44), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testZaehleBuchstaben_Leereswort(void) { |
||||
|
|
||||
|
char wort2[] = "Test"; |
||||
|
|
||||
|
int anzahl2 = zaehleBuchstaben(wort2, 'z'); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((anzahl2)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(50), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testUmdrehenWort_normalesWort(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
char wort1[] = "Hello"; |
||||
|
|
||||
|
umdrehenWort(wort1); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("olleH")), (const char*)((wort1)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(57)); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testUmdrehenWort_leeresWort(void) { |
||||
|
|
||||
|
char wort2[] = ""; |
||||
|
|
||||
|
umdrehenWort(wort2); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("")), (const char*)((wort2)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(63)); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testUmdrehenWort_einBuchstabe(void) { |
||||
|
|
||||
|
char wort3[] = "A"; |
||||
|
|
||||
|
umdrehenWort(wort3); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("A")), (const char*)((wort3)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(69)); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testSucheBuchstabe_existiert(void) { |
||||
|
|
||||
|
char wort1[] = "Programming"; |
||||
|
|
||||
|
int position = sucheBuchstabe(wort1, 'g'); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((3)), (UNITY_INT)((position)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(75), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testSucheBuchstabe_existiertnicht(void) { |
||||
|
|
||||
|
char wort2[] = "Testing"; |
||||
|
|
||||
|
int position = sucheBuchstabe(wort2, 'z'); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((-1)), (UNITY_INT)((position)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(82), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testSucheBuchstabe_leeresWort(void) { |
||||
|
|
||||
|
char wort3[] = ""; |
||||
|
|
||||
|
int position = sucheBuchstabe(wort3, 'a'); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((-1)), (UNITY_INT)((position)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(88), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
build/test/out/c/WortSpiel.o: src/WortSpiel.c src/WortSpiel.h |
@ -0,0 +1,4 @@ |
|||||
|
build/test/out/c/test_WortSpiel.o: test/test_WortSpiel.c \ |
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ |
||||
|
src/WortSpiel.h |
@ -0,0 +1,4 @@ |
|||||
|
build/test/out/c/test_WortSpiel_runner.o: \ |
||||
|
build/test/runners/test_WortSpiel_runner.c \ |
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
||||
|
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
@ -0,0 +1,223 @@ |
|||||
|
#include "src/WortSpiel.h" |
||||
|
#include "C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
void setUp(void) |
||||
|
|
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void tearDown(void) |
||||
|
|
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testLoescheBuchstaben_Buchstabeexistiert(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
char wort1[] = "Beispiel"; |
||||
|
|
||||
|
loescheBuchstaben(wort1, 'i'); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Bespel")), (const char*)((wort1)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(19)); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testLoescheBuchstaben_Buchstabeexistiertnicht(void) { |
||||
|
|
||||
|
char wort2[] = "Test"; |
||||
|
|
||||
|
loescheBuchstaben(wort2, 'z'); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("Test")), (const char*)((wort2)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(25)); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testLoescheBuchstaben_Leereswort(void) { |
||||
|
|
||||
|
char wort3[] = ""; |
||||
|
|
||||
|
loescheBuchstaben(wort3, 'a'); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("")), (const char*)((wort3)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(31)); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testZaehleBuchstaben_Buchstabenexistiert(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
char wort1[] = "Beispiel"; |
||||
|
|
||||
|
int anzahl1 = zaehleBuchstaben(wort1, 'i'); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((anzahl1)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(38), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testZaehleBuchstaben_Buchstabenexistiertnicht(void) { |
||||
|
|
||||
|
char wort2[] = "Test"; |
||||
|
|
||||
|
int anzahl2 = zaehleBuchstaben(wort2, 'z'); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((anzahl2)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(44), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testZaehleBuchstaben_Leereswort(void) { |
||||
|
|
||||
|
char wort2[] = "Test"; |
||||
|
|
||||
|
int anzahl2 = zaehleBuchstaben(wort2, 'z'); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((anzahl2)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(50), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testUmdrehenWort_normalesWort(void) { |
||||
|
|
||||
|
|
||||
|
|
||||
|
char wort1[] = "Hello"; |
||||
|
|
||||
|
umdrehenWort(wort1); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("olleH")), (const char*)((wort1)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(57)); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testUmdrehenWort_leeresWort(void) { |
||||
|
|
||||
|
char wort2[] = ""; |
||||
|
|
||||
|
umdrehenWort(wort2); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("")), (const char*)((wort2)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(63)); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testUmdrehenWort_einBuchstabe(void) { |
||||
|
|
||||
|
char wort3[] = "A"; |
||||
|
|
||||
|
umdrehenWort(wort3); |
||||
|
|
||||
|
UnityAssertEqualString((const char*)(("A")), (const char*)((wort3)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(69)); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testSucheBuchstabe_existiert(void) { |
||||
|
|
||||
|
char wort1[] = "Programming"; |
||||
|
|
||||
|
int position = sucheBuchstabe(wort1, 'g'); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((3)), (UNITY_INT)((position)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(75), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testSucheBuchstabe_existiertnicht(void) { |
||||
|
|
||||
|
char wort2[] = "Testing"; |
||||
|
|
||||
|
int position = sucheBuchstabe(wort2, 'z'); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((-1)), (UNITY_INT)((position)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(82), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
void testSucheBuchstabe_leeresWort(void) { |
||||
|
|
||||
|
char wort3[] = ""; |
||||
|
|
||||
|
int position = sucheBuchstabe(wort3, 'a'); |
||||
|
|
||||
|
UnityAssertEqualNumber((UNITY_INT)((-1)), (UNITY_INT)((position)), ( |
||||
|
|
||||
|
((void *)0) |
||||
|
|
||||
|
), (UNITY_UINT)(88), UNITY_DISPLAY_STYLE_INT); |
||||
|
|
||||
|
} |
@ -0,0 +1,3 @@ |
|||||
|
--- |
||||
|
- C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h |
||||
|
- src/WortSpiel.h |
@ -0,0 +1,62 @@ |
|||||
|
--- |
||||
|
:source: |
||||
|
:path: test |
||||
|
:file: test_WortSpiel.c |
||||
|
:successes: |
||||
|
- :test: testLoescheBuchstaben_Buchstabeexistiert |
||||
|
:line: 15 |
||||
|
:message: '' |
||||
|
:unity_test_time: 0 |
||||
|
- :test: testLoescheBuchstaben_Buchstabeexistiertnicht |
||||
|
:line: 22 |
||||
|
:message: '' |
||||
|
:unity_test_time: 0 |
||||
|
- :test: testLoescheBuchstaben_Leereswort |
||||
|
:line: 28 |
||||
|
:message: '' |
||||
|
:unity_test_time: 0 |
||||
|
- :test: testZaehleBuchstaben_Buchstabenexistiert |
||||
|
:line: 34 |
||||
|
:message: '' |
||||
|
:unity_test_time: 0 |
||||
|
- :test: testZaehleBuchstaben_Buchstabenexistiertnicht |
||||
|
:line: 41 |
||||
|
:message: '' |
||||
|
:unity_test_time: 0 |
||||
|
- :test: testZaehleBuchstaben_Leereswort |
||||
|
:line: 47 |
||||
|
:message: '' |
||||
|
:unity_test_time: 0 |
||||
|
- :test: testUmdrehenWort_normalesWort |
||||
|
:line: 53 |
||||
|
:message: '' |
||||
|
:unity_test_time: 0 |
||||
|
- :test: testUmdrehenWort_leeresWort |
||||
|
:line: 60 |
||||
|
:message: '' |
||||
|
:unity_test_time: 0 |
||||
|
- :test: testUmdrehenWort_einBuchstabe |
||||
|
:line: 66 |
||||
|
:message: '' |
||||
|
:unity_test_time: 0 |
||||
|
- :test: testSucheBuchstabe_existiert |
||||
|
:line: 72 |
||||
|
:message: '' |
||||
|
:unity_test_time: 0 |
||||
|
- :test: testSucheBuchstabe_existiertnicht |
||||
|
:line: 79 |
||||
|
:message: '' |
||||
|
:unity_test_time: 0 |
||||
|
- :test: testSucheBuchstabe_leeresWort |
||||
|
:line: 85 |
||||
|
:message: '' |
||||
|
:unity_test_time: 0 |
||||
|
:failures: [] |
||||
|
:ignores: [] |
||||
|
:counts: |
||||
|
:total: 12 |
||||
|
:passed: 12 |
||||
|
:failed: 0 |
||||
|
:ignored: 0 |
||||
|
:stdout: [] |
||||
|
:time: 0.8378995999992185 |
@ -0,0 +1,103 @@ |
|||||
|
/* AUTOGENERATED FILE. DO NOT EDIT. */ |
||||
|
|
||||
|
/*=======Automagically Detected Files To Include=====*/ |
||||
|
#include "unity.h" |
||||
|
|
||||
|
int GlobalExpectCount; |
||||
|
int GlobalVerifyOrder; |
||||
|
char* GlobalOrderError; |
||||
|
|
||||
|
/*=======External Functions This Runner Calls=====*/ |
||||
|
extern void setUp(void); |
||||
|
extern void tearDown(void); |
||||
|
extern void testLoescheBuchstaben_Buchstabeexistiert(void); |
||||
|
extern void testLoescheBuchstaben_Buchstabeexistiertnicht(void); |
||||
|
extern void testLoescheBuchstaben_Leereswort(void); |
||||
|
extern void testZaehleBuchstaben_Buchstabenexistiert(void); |
||||
|
extern void testZaehleBuchstaben_Buchstabenexistiertnicht(void); |
||||
|
extern void testZaehleBuchstaben_Leereswort(void); |
||||
|
extern void testUmdrehenWort_normalesWort(void); |
||||
|
extern void testUmdrehenWort_leeresWort(void); |
||||
|
extern void testUmdrehenWort_einBuchstabe(void); |
||||
|
extern void testSucheBuchstabe_existiert(void); |
||||
|
extern void testSucheBuchstabe_existiertnicht(void); |
||||
|
extern void testSucheBuchstabe_leeresWort(void); |
||||
|
|
||||
|
|
||||
|
/*=======Mock Management=====*/ |
||||
|
static void CMock_Init(void) |
||||
|
{ |
||||
|
GlobalExpectCount = 0; |
||||
|
GlobalVerifyOrder = 0; |
||||
|
GlobalOrderError = NULL; |
||||
|
} |
||||
|
static void CMock_Verify(void) |
||||
|
{ |
||||
|
} |
||||
|
static void CMock_Destroy(void) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
/*=======Test Reset Options=====*/ |
||||
|
void resetTest(void); |
||||
|
void resetTest(void) |
||||
|
{ |
||||
|
tearDown(); |
||||
|
CMock_Verify(); |
||||
|
CMock_Destroy(); |
||||
|
CMock_Init(); |
||||
|
setUp(); |
||||
|
} |
||||
|
void verifyTest(void); |
||||
|
void verifyTest(void) |
||||
|
{ |
||||
|
CMock_Verify(); |
||||
|
} |
||||
|
|
||||
|
/*=======Test Runner Used To Run Each Test=====*/ |
||||
|
static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num) |
||||
|
{ |
||||
|
Unity.CurrentTestName = name; |
||||
|
Unity.CurrentTestLineNumber = line_num; |
||||
|
#ifdef UNITY_USE_COMMAND_LINE_ARGS |
||||
|
if (!UnityTestMatches()) |
||||
|
return; |
||||
|
#endif |
||||
|
Unity.NumberOfTests++; |
||||
|
UNITY_CLR_DETAILS(); |
||||
|
UNITY_EXEC_TIME_START(); |
||||
|
CMock_Init(); |
||||
|
if (TEST_PROTECT()) |
||||
|
{ |
||||
|
setUp(); |
||||
|
func(); |
||||
|
} |
||||
|
if (TEST_PROTECT()) |
||||
|
{ |
||||
|
tearDown(); |
||||
|
CMock_Verify(); |
||||
|
} |
||||
|
CMock_Destroy(); |
||||
|
UNITY_EXEC_TIME_STOP(); |
||||
|
UnityConcludeTest(); |
||||
|
} |
||||
|
|
||||
|
/*=======MAIN=====*/ |
||||
|
int main(void) |
||||
|
{ |
||||
|
UnityBegin("test_WortSpiel.c"); |
||||
|
run_test(testLoescheBuchstaben_Buchstabeexistiert, "testLoescheBuchstaben_Buchstabeexistiert", 15); |
||||
|
run_test(testLoescheBuchstaben_Buchstabeexistiertnicht, "testLoescheBuchstaben_Buchstabeexistiertnicht", 22); |
||||
|
run_test(testLoescheBuchstaben_Leereswort, "testLoescheBuchstaben_Leereswort", 28); |
||||
|
run_test(testZaehleBuchstaben_Buchstabenexistiert, "testZaehleBuchstaben_Buchstabenexistiert", 34); |
||||
|
run_test(testZaehleBuchstaben_Buchstabenexistiertnicht, "testZaehleBuchstaben_Buchstabenexistiertnicht", 41); |
||||
|
run_test(testZaehleBuchstaben_Leereswort, "testZaehleBuchstaben_Leereswort", 47); |
||||
|
run_test(testUmdrehenWort_normalesWort, "testUmdrehenWort_normalesWort", 53); |
||||
|
run_test(testUmdrehenWort_leeresWort, "testUmdrehenWort_leeresWort", 60); |
||||
|
run_test(testUmdrehenWort_einBuchstabe, "testUmdrehenWort_einBuchstabe", 66); |
||||
|
run_test(testSucheBuchstabe_existiert, "testSucheBuchstabe_existiert", 72); |
||||
|
run_test(testSucheBuchstabe_existiertnicht, "testSucheBuchstabe_existiertnicht", 79); |
||||
|
run_test(testSucheBuchstabe_leeresWort, "testSucheBuchstabe_leeresWort", 85); |
||||
|
|
||||
|
return UnityEnd(); |
||||
|
} |
@ -0,0 +1,86 @@ |
|||||
|
#include "WortSpiel.h" |
||||
|
#include <stdio.h> |
||||
|
#include <string.h> |
||||
|
|
||||
|
//Funktion zum loeschen von einem Buchstaben |
||||
|
void loescheBuchstaben(char *wort, char buchstabe) { |
||||
|
int laenge = strlen(wort); |
||||
|
int i, j = 0; |
||||
|
|
||||
|
for (i = 0; i < laenge; i++) { |
||||
|
if (wort[i] != buchstabe) { |
||||
|
wort[j++] = wort[i]; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
wort[j] = '\0'; |
||||
|
} |
||||
|
|
||||
|
//Funktion zum zaehlen wie oft ein Buchstabe vorkommt |
||||
|
int zaehleBuchstaben(const char *wort, char buchstabe) { |
||||
|
int zaehler = 0; |
||||
|
int laenge = strlen(wort); |
||||
|
|
||||
|
while (*wort) { |
||||
|
if (*wort == buchstabe) { |
||||
|
zaehler++; |
||||
|
} |
||||
|
wort++; |
||||
|
} |
||||
|
|
||||
|
return zaehler; |
||||
|
} |
||||
|
//Funktion zum Umdrehen der Wörter |
||||
|
void umdrehenWort(char *wort) { |
||||
|
int laenge = strlen(wort); |
||||
|
|
||||
|
for (int i = 0, j = laenge - 1; i < j; i++, j--) { |
||||
|
char temp = wort[i]; |
||||
|
wort[i] = wort[j]; |
||||
|
wort[j] = temp; |
||||
|
} |
||||
|
} |
||||
|
//Funktion zum suchen von einem Buchstaben |
||||
|
int sucheBuchstabe(const char *wort, char buchstabe) { |
||||
|
int laenge = strlen(wort); |
||||
|
|
||||
|
for (int i = 0; i < laenge; i++) { |
||||
|
if (wort[i] == buchstabe) { |
||||
|
return i; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return -1; // Buchstabe nicht gefunden |
||||
|
} |
||||
|
|
||||
|
int run_wortspiel() { |
||||
|
char wort[50]; |
||||
|
char buchstabe; |
||||
|
|
||||
|
printf("Gib ein Wort ein: "); |
||||
|
scanf("%s", wort); |
||||
|
|
||||
|
printf("Gib den zu löschenden Buchstaben ein: "); |
||||
|
scanf(" %c", &buchstabe); |
||||
|
|
||||
|
loescheBuchstaben(wort, buchstabe); |
||||
|
|
||||
|
printf("Wort nach dem Löschen des Buchstabens: %s\n", wort); |
||||
|
|
||||
|
int anzahl = zaehleBuchstaben(wort, buchstabe); |
||||
|
printf("Der Buchstabe '%c' kommt %d Mal vor.\n", buchstabe, anzahl); |
||||
|
|
||||
|
umdrehenWort(wort); |
||||
|
printf("Wort nach dem Umdrehen: %s\n", wort); |
||||
|
|
||||
|
int index = sucheBuchstabe(wort, buchstabe); |
||||
|
if (index != -1) { |
||||
|
printf("Der Buchstabe '%c' wurde an der Position %d gefunden.\n", buchstabe, index); |
||||
|
} else { |
||||
|
printf("Der Buchstabe '%c' wurde nicht gefunden.\n", buchstabe); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
return 0; |
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
#ifndef WORTSPIEL_H |
||||
|
#define WORTSPIEL_H |
||||
|
|
||||
|
void loescheBuchstaben(char* wort, char buchstabe); |
||||
|
int zaehleBuchstaben(const char* wort, char buchstabe); |
||||
|
void umdrehenWort(char* wort); |
||||
|
void testSucheBuchstabe_existiert(void); |
||||
|
|
||||
|
#endif // WORTSPIEL_H |
@ -0,0 +1,93 @@ |
|||||
|
#ifdef TEST |
||||
|
|
||||
|
#include "unity.h" |
||||
|
|
||||
|
#include "WortSpiel.h" |
||||
|
|
||||
|
void setUp(void) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
void tearDown(void) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
void testLoescheBuchstaben_Buchstabeexistiert(void) { |
||||
|
// Testfall 1: Buchstabe existiert im Wort |
||||
|
char wort1[] = "Beispiel"; |
||||
|
loescheBuchstaben(wort1, 'i'); |
||||
|
TEST_ASSERT_EQUAL_STRING("Bespel", wort1); |
||||
|
} |
||||
|
|
||||
|
void testLoescheBuchstaben_Buchstabeexistiertnicht(void) { |
||||
|
char wort2[] = "Test"; |
||||
|
loescheBuchstaben(wort2, 'z'); |
||||
|
TEST_ASSERT_EQUAL_STRING("Test", wort2); |
||||
|
} |
||||
|
|
||||
|
void testLoescheBuchstaben_Leereswort(void) { |
||||
|
char wort3[] = ""; |
||||
|
loescheBuchstaben(wort3, 'a'); |
||||
|
TEST_ASSERT_EQUAL_STRING("", wort3); |
||||
|
} |
||||
|
|
||||
|
void testZaehleBuchstaben_Buchstabenexistiert(void) { |
||||
|
// Testfall 1: Buchstabe existiert im Wort |
||||
|
char wort1[] = "Beispiel"; |
||||
|
int anzahl1 = zaehleBuchstaben(wort1, 'i'); |
||||
|
TEST_ASSERT_EQUAL_INT(2, anzahl1); |
||||
|
} |
||||
|
|
||||
|
void testZaehleBuchstaben_Buchstabenexistiertnicht(void) { |
||||
|
char wort2[] = "Test"; |
||||
|
int anzahl2 = zaehleBuchstaben(wort2, 'z'); |
||||
|
TEST_ASSERT_EQUAL_INT(0, anzahl2); |
||||
|
} |
||||
|
|
||||
|
void testZaehleBuchstaben_Leereswort(void) { |
||||
|
char wort2[] = "Test"; |
||||
|
int anzahl2 = zaehleBuchstaben(wort2, 'z'); |
||||
|
TEST_ASSERT_EQUAL_INT(0, anzahl2); |
||||
|
} |
||||
|
|
||||
|
void testUmdrehenWort_normalesWort(void) { |
||||
|
// Testfall 1: Umdrehen eines normalen Wortes |
||||
|
char wort1[] = "Hello"; |
||||
|
umdrehenWort(wort1); |
||||
|
TEST_ASSERT_EQUAL_STRING("olleH", wort1); |
||||
|
} |
||||
|
|
||||
|
void testUmdrehenWort_leeresWort(void) { |
||||
|
char wort2[] = ""; |
||||
|
umdrehenWort(wort2); |
||||
|
TEST_ASSERT_EQUAL_STRING("", wort2); |
||||
|
} |
||||
|
|
||||
|
void testUmdrehenWort_einBuchstabe(void) { |
||||
|
char wort3[] = "A"; |
||||
|
umdrehenWort(wort3); |
||||
|
TEST_ASSERT_EQUAL_STRING("A", wort3); |
||||
|
} |
||||
|
|
||||
|
void testSucheBuchstabe_existiert(void) { |
||||
|
char wort1[] = "Programming"; |
||||
|
int position = sucheBuchstabe(wort1, 'g'); |
||||
|
TEST_ASSERT_EQUAL_INT(3, position); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void testSucheBuchstabe_existiertnicht(void) { |
||||
|
char wort2[] = "Testing"; |
||||
|
int position = sucheBuchstabe(wort2, 'z'); |
||||
|
TEST_ASSERT_EQUAL_INT(-1, position); |
||||
|
} |
||||
|
|
||||
|
void testSucheBuchstabe_leeresWort(void) { |
||||
|
char wort3[] = ""; |
||||
|
int position = sucheBuchstabe(wort3, 'a'); |
||||
|
TEST_ASSERT_EQUAL_INT(-1, position); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
#endif // TEST |
Write
Preview
Loading…
Cancel
Save
Reference in new issue