Browse Source
Merge branch 'Ulrich' into 'main'
Merge branch 'Ulrich' into 'main'
Ulrich See merge request pmuw_projekt/pmuw_projekt_notebinder!41remotes/origin/Saba
fdai7899
11 months ago
58 changed files with 1108 additions and 13 deletions
-
0And
-
0Shell
-
0build/release/dependencies/force_build
-
1build/release/dependencies/top.d
-
BINbuild/release/out/c/top.o
-
4build/test/cache/defines_dependency.yml
-
12build/test/cache/input.yml
-
79build/test/cache/test_add.c
-
47build/test/cache/test_factorial.c
-
79build/test/cache/test_pow.c
-
2build/test/cache/test_template.c
-
1build/test/dependencies/calculator.d
-
0build/test/dependencies/force_build
-
4build/test/dependencies/test_add.d
-
3build/test/dependencies/test_add_runner.d
-
4build/test/dependencies/test_factorial.d
-
4build/test/dependencies/test_factorial_runner.d
-
4build/test/dependencies/test_pow.d
-
3build/test/dependencies/test_pow_runner.d
-
4build/test/dependencies/test_template_runner.d
-
BINbuild/test/out/c/calculator.o
-
BINbuild/test/out/c/test_add.o
-
BINbuild/test/out/c/test_add_runner.o
-
BINbuild/test/out/c/test_factorial.o
-
BINbuild/test/out/c/test_factorial_runner.o
-
BINbuild/test/out/c/test_pow.o
-
BINbuild/test/out/c/test_pow_runner.o
-
BINbuild/test/out/c/test_template_runner.o
-
BINbuild/test/out/test_add.out
-
BINbuild/test/out/test_factorial.out
-
BINbuild/test/out/test_pow.out
-
BINbuild/test/out/test_template.out
-
79build/test/preprocess/files/test_add.c
-
47build/test/preprocess/files/test_factorial.c
-
79build/test/preprocess/files/test_pow.c
-
2build/test/preprocess/files/test_template.c
-
3build/test/preprocess/includes/test_add.c
-
3build/test/preprocess/includes/test_factorial.c
-
3build/test/preprocess/includes/test_pow.c
-
2build/test/preprocess/includes/test_template.c
-
22build/test/results/test_add.pass
-
18build/test/results/test_factorial.pass
-
22build/test/results/test_pow.pass
-
4build/test/results/test_template.pass
-
83build/test/runners/test_add_runner.c
-
81build/test/runners/test_factorial_runner.c
-
83build/test/runners/test_pow_runner.c
-
158src/main/c/Calculator/calculator.c
-
BINsrc/main/c/Calculator/calculator.exe
-
8src/main/c/Calculator/calculator.h
-
29src/main/c/Quiz/Quiz_2.c
-
6src/main/c/Quiz/Quiz_2.h
-
57src/main/c/Quiz/top.c
-
7src/main/c/Quiz/top.h
-
8src/main/c/main.c
-
1team.md
-
25test/Calculator/test_factorial.c
-
40test/Calculator/test_pow.c
@ -0,0 +1 @@ |
|||
build/release/out/c/top.o: src/main/c/Quiz/top.c |
@ -0,0 +1,79 @@ |
|||
#include "build/temp/../../src/main/c/Calculator/calculator.h" |
|||
#include "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void setUp(void){ |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
void tearDown(void){ |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_pow_N_N(void){ |
|||
|
|||
|
|||
|
|||
double result; |
|||
|
|||
double b = 3; |
|||
|
|||
double a = 3; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
result = pow(a, b); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((27)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_pow_Z_N(void){ |
|||
|
|||
|
|||
|
|||
double result; |
|||
|
|||
double b = 3; |
|||
|
|||
double a = -3; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
result = pow(a, b); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((-27)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(36), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
@ -0,0 +1,47 @@ |
|||
#include "src/main/c/Calculator/calculator.h" |
|||
#include "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void setUp(void){ |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
void tearDown(void){ |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_factorial_4(void){ |
|||
|
|||
|
|||
|
|||
double result; |
|||
|
|||
double a = 4; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
result = factorial(a); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((24)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(22), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
@ -0,0 +1,79 @@ |
|||
#include "build/temp/../../src/main/c/Calculator/calculator.h" |
|||
#include "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void setUp(void){ |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
void tearDown(void){ |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_pow_N_N(void){ |
|||
|
|||
|
|||
|
|||
double result; |
|||
|
|||
double b = 3; |
|||
|
|||
double a = 3; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
result = pow(a, b); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((27)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_pow_Z_N(void){ |
|||
|
|||
|
|||
|
|||
double result; |
|||
|
|||
double b = 3; |
|||
|
|||
double a = -3; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
result = pow(a, b); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((-27)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(36), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
@ -0,0 +1 @@ |
|||
build/test/out/c/calculator.o: src/main/c/Calculator/calculator.c |
@ -0,0 +1,4 @@ |
|||
build/test/out/c/test_add.o: test/Calculator/test_add.c \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ |
|||
test/Calculator/../../src/main/c/Calculator/calculator.h |
@ -0,0 +1,3 @@ |
|||
build/test/out/c/test_add_runner.o: build/test/runners/test_add_runner.c \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
@ -0,0 +1,4 @@ |
|||
build/test/out/c/test_factorial.o: test/Calculator/test_factorial.c \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ |
|||
src/main/c/Calculator/calculator.h |
@ -0,0 +1,4 @@ |
|||
build/test/out/c/test_factorial_runner.o: \ |
|||
build/test/runners/test_factorial_runner.c \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
@ -0,0 +1,4 @@ |
|||
build/test/out/c/test_pow.o: test/Calculator/test_pow.c \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ |
|||
test/Calculator/../../src/main/c/Calculator/calculator.h |
@ -0,0 +1,3 @@ |
|||
build/test/out/c/test_pow_runner.o: build/test/runners/test_pow_runner.c \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
@ -1,4 +1,4 @@ |
|||
build/test/out/c/test_template_runner.o: \ |
|||
build/test/runners/test_template_runner.c \ |
|||
/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|||
/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
@ -0,0 +1,79 @@ |
|||
#include "build/temp/../../src/main/c/Calculator/calculator.h" |
|||
#include "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void setUp(void){ |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
void tearDown(void){ |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_pow_N_N(void){ |
|||
|
|||
|
|||
|
|||
double result; |
|||
|
|||
double b = 3; |
|||
|
|||
double a = 3; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
result = pow(a, b); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((27)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_pow_Z_N(void){ |
|||
|
|||
|
|||
|
|||
double result; |
|||
|
|||
double b = 3; |
|||
|
|||
double a = -3; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
result = pow(a, b); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((-27)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(36), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
@ -0,0 +1,47 @@ |
|||
#include "src/main/c/Calculator/calculator.h" |
|||
#include "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void setUp(void){ |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
void tearDown(void){ |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_factorial_4(void){ |
|||
|
|||
|
|||
|
|||
double result; |
|||
|
|||
double a = 4; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
result = factorial(a); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((24)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(22), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
@ -0,0 +1,79 @@ |
|||
#include "build/temp/../../src/main/c/Calculator/calculator.h" |
|||
#include "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void setUp(void){ |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
void tearDown(void){ |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_pow_N_N(void){ |
|||
|
|||
|
|||
|
|||
double result; |
|||
|
|||
double b = 3; |
|||
|
|||
double a = 3; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
result = pow(a, b); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((27)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_pow_Z_N(void){ |
|||
|
|||
|
|||
|
|||
double result; |
|||
|
|||
double b = 3; |
|||
|
|||
double a = -3; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
result = pow(a, b); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((-27)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(36), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
@ -0,0 +1,3 @@ |
|||
--- |
|||
- "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
- build/temp/../../src/main/c/Calculator/calculator.h |
@ -0,0 +1,3 @@ |
|||
--- |
|||
- "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
- src/main/c/Calculator/calculator.h |
@ -0,0 +1,3 @@ |
|||
--- |
|||
- "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
- build/temp/../../src/main/c/Calculator/calculator.h |
@ -1,3 +1,3 @@ |
|||
--- |
|||
- "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
- "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
- src/main/c/Template/game100.h |
@ -0,0 +1,22 @@ |
|||
--- |
|||
:source: |
|||
:path: test/Calculator |
|||
:file: test_add.c |
|||
:successes: |
|||
- :test: test_pow_N_N |
|||
:line: 13 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_pow_Z_N |
|||
:line: 26 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
:failures: [] |
|||
:ignores: [] |
|||
:counts: |
|||
:total: 2 |
|||
:passed: 2 |
|||
:failed: 0 |
|||
:ignored: 0 |
|||
:stdout: [] |
|||
:time: 0.007150935009121895 |
@ -0,0 +1,18 @@ |
|||
--- |
|||
:source: |
|||
:path: test/Calculator |
|||
:file: test_factorial.c |
|||
:successes: |
|||
- :test: test_factorial_4 |
|||
:line: 13 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
:failures: [] |
|||
:ignores: [] |
|||
:counts: |
|||
:total: 1 |
|||
:passed: 1 |
|||
:failed: 0 |
|||
:ignored: 0 |
|||
:stdout: [] |
|||
:time: 0.0060175769904162735 |
@ -0,0 +1,22 @@ |
|||
--- |
|||
:source: |
|||
:path: test/Calculator |
|||
:file: test_pow.c |
|||
:successes: |
|||
- :test: test_pow_N_N |
|||
:line: 13 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_pow_Z_N |
|||
:line: 26 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
:failures: [] |
|||
:ignores: [] |
|||
:counts: |
|||
:total: 2 |
|||
:passed: 2 |
|||
:failed: 0 |
|||
:ignored: 0 |
|||
:stdout: [] |
|||
:time: 0.0062921050121076405 |
@ -0,0 +1,83 @@ |
|||
/* 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 test_pow_N_N(void); |
|||
extern void test_pow_Z_N(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_add.c"); |
|||
run_test(test_pow_N_N, "test_pow_N_N", 13); |
|||
run_test(test_pow_Z_N, "test_pow_Z_N", 26); |
|||
|
|||
return UnityEnd(); |
|||
} |
@ -0,0 +1,81 @@ |
|||
/* 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 test_factorial_4(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_factorial.c"); |
|||
run_test(test_factorial_4, "test_factorial_4", 13); |
|||
|
|||
return UnityEnd(); |
|||
} |
@ -0,0 +1,83 @@ |
|||
/* 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 test_pow_N_N(void); |
|||
extern void test_pow_Z_N(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_pow.c"); |
|||
run_test(test_pow_N_N, "test_pow_N_N", 13); |
|||
run_test(test_pow_Z_N, "test_pow_Z_N", 26); |
|||
|
|||
return UnityEnd(); |
|||
} |
@ -0,0 +1,158 @@ |
|||
#include <stdio.h> |
|||
#define M_PI 3.14159265358979323 |
|||
|
|||
|
|||
// Function prototypes |
|||
void displayMenu(); |
|||
double performOperation(int choice, double num1, double num2); |
|||
double getDoubleInput(const char *message); |
|||
int getIntInput(const char *message); |
|||
double factorial(double num); |
|||
double permutation(int n, int r); |
|||
double combination(int n, int r); |
|||
double pow(double num1, double num2); |
|||
|
|||
int calculator() { |
|||
int choice; |
|||
double num1, num2, result; |
|||
|
|||
|
|||
do { |
|||
displayMenu(); |
|||
printf("Enter your choice: "); |
|||
scanf("%d", &choice); |
|||
if (choice >= 1 && choice <= 19) { |
|||
if (choice >= 9 && choice <= 17) { |
|||
num1 = getDoubleInput("Enter a number: "); |
|||
} else if (choice >= 1 && choice <= 8) { |
|||
printf("Enter two numbers: "); |
|||
scanf("%lf %lf", &num1, &num2); |
|||
} else if (choice == 18 || choice == 19) { |
|||
int n = getIntInput("Enter n: "); |
|||
int r = getIntInput("Enter r: "); |
|||
num1 = n; |
|||
num2 = r; |
|||
} |
|||
if (choice != 4 || (choice == 4 && num2 != 0)) { |
|||
result = performOperation(choice, num1, num2); |
|||
printf("Result: %.2lf\n", result); |
|||
} else { |
|||
printf("Error: Division by zero\n"); |
|||
} |
|||
} else if (choice != 20) { |
|||
printf("Invalid choice\n"); |
|||
} |
|||
} |
|||
|
|||
while (choice != 20); |
|||
|
|||
return 0; |
|||
} |
|||
// Function definitions |
|||
void displayMenu() { |
|||
printf("\nAdvaced Calculator\n"); |
|||
printf("1. Add\n"); |
|||
printf("2. Subtract\n"); |
|||
printf("3. Multiply\n"); |
|||
printf("4. Divide\n"); |
|||
printf("5. Exponentiation\n"); |
|||
printf("6. Modulus\n"); |
|||
printf("7. Logarithm\n"); |
|||
printf("8. Potential\n"); |
|||
printf("9. Square Root\n"); |
|||
printf("10. Square\n"); |
|||
printf("11. Cube\n"); |
|||
printf("12. Cube Root\n"); |
|||
printf("13. Factorial\n"); |
|||
printf("14. Power\n"); |
|||
printf("15. Sine\n"); |
|||
printf("16. Cosine\n"); |
|||
printf("17. Tangent\n"); |
|||
printf("18. Permutation\n"); |
|||
printf("19. Combination\n"); |
|||
printf("20. Exit\n"); |
|||
} |
|||
double performOperation(int choice, double num1, double num2) { |
|||
switch (choice) { |
|||
case 1: |
|||
return num1 + num2; |
|||
case 2: |
|||
return num1 - num2; |
|||
case 3: |
|||
return num1 * num2; |
|||
case 4: |
|||
return num1 / num2; |
|||
case 5: |
|||
return pow(num1, num2); |
|||
case 6: |
|||
return 0;// fmod(num1, num2); |
|||
case 7: |
|||
return 0;// log(num1); |
|||
case 8: |
|||
return pow(num1, num2); |
|||
case 9: |
|||
return 0;// sqrt(num1); |
|||
case 10: |
|||
return num1 * num1; |
|||
case 11: |
|||
return num1 * num1 * num1; |
|||
case 12: |
|||
return 0;// cbrt(num1); |
|||
case 13: |
|||
return factorial(num1); |
|||
case 14: |
|||
return pow(num1, num2); |
|||
case 15: |
|||
return 0;// sin(num1 * M_PI / 180.0); |
|||
case 16: |
|||
return 0;// cos(num1 * M_PI / 180.0); |
|||
case 17: |
|||
return 0;// tan(num1 * M_PI / 180.0); |
|||
|
|||
case 18: |
|||
return permutation((int)num1, (int)num2); |
|||
case 19: |
|||
return combination((int)num1, (int)num2); |
|||
default: |
|||
return 0.0; |
|||
} |
|||
} |
|||
double getDoubleInput(const char *message) { |
|||
double input; |
|||
printf("%s", message); |
|||
scanf("%lf", &input); |
|||
return input; |
|||
} |
|||
double factorial(double num) { |
|||
if (num == 0) { |
|||
return 1; |
|||
} else { |
|||
return num * factorial(num - 1); |
|||
} |
|||
} |
|||
double permutation(int n, int r) { |
|||
double result = 1; |
|||
for (int i = 0; i < r; i++) { |
|||
result *= (n - i); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
double combination(int n, int r) { |
|||
return permutation(n, r) / factorial(r); |
|||
} |
|||
|
|||
int getIntInput(const char *message) { |
|||
int input; |
|||
printf("%s", message); |
|||
scanf("%d", &input); |
|||
return input; |
|||
} |
|||
|
|||
double pow(double num1, double num2){ |
|||
double product = 1; |
|||
for(int i = 0; i < num2; i++){ |
|||
product *= num1; |
|||
} |
|||
return product; |
|||
} |
@ -0,0 +1,8 @@ |
|||
#ifndef CALCULATOR_H |
|||
#define CALCULATOR_H |
|||
|
|||
int calculator(); |
|||
double pow(double num1, double num2); |
|||
double factorial(double num); |
|||
|
|||
#endif |
@ -0,0 +1,29 @@ |
|||
#include <stdio.h> |
|||
|
|||
int quiz_2() |
|||
{ |
|||
int secretNumber=5; |
|||
int guess; |
|||
int guessCount = 0; |
|||
int guessLimit = 3; |
|||
int outOfGuesses =0; |
|||
|
|||
while (guess != secretNumber && outOfGuesses == 0) |
|||
{ |
|||
if(guessCount < guessLimit) |
|||
{ |
|||
printf("Enter a number: "); |
|||
scanf("%d",&guess); |
|||
guessCount++; |
|||
} else { |
|||
outOfGuesses = 1; |
|||
} |
|||
} |
|||
if (outOfGuesses == 1) |
|||
{ |
|||
printf("Out of guesses"); |
|||
}else { |
|||
printf("You Win!"); |
|||
} |
|||
return 0; |
|||
} |
@ -0,0 +1,6 @@ |
|||
#ifndef QUIZ_2_H |
|||
#define QUIZ_2_H |
|||
|
|||
void quiz_2(); |
|||
|
|||
#endif //QUIZ_2_H |
@ -0,0 +1,57 @@ |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <string.h> |
|||
|
|||
// Struktur für eine Frage im Quiz |
|||
struct Frage { |
|||
char text[100]; |
|||
char antwort1[50]; |
|||
char antwort2[50]; |
|||
char antwort3[50]; |
|||
int korrekteAntwort; |
|||
}; |
|||
|
|||
// Funktion, um eine Frage zu erstellen |
|||
struct Frage erstelleFrage(char *text, char *antwort1, char *antwort2, char *antwort3, int korrekteAntwort) { |
|||
struct Frage frage; |
|||
strcpy(frage.text, text); |
|||
strcpy(frage.antwort1, antwort1); |
|||
strcpy(frage.antwort2, antwort2); |
|||
strcpy(frage.antwort3, antwort3); |
|||
frage.korrekteAntwort = korrekteAntwort; |
|||
return frage; |
|||
} |
|||
|
|||
// Funktion, um eine Frage anzuzeigen und die Antwort des Benutzers zu überprüfen |
|||
int zeigeFrage(struct Frage frage) { |
|||
printf("%s\n", frage.text); |
|||
printf("1. %s\n", frage.antwort1); |
|||
printf("2. %s\n", frage.antwort2); |
|||
printf("3. %s\n", frage.antwort3); |
|||
|
|||
int benutzerAntwort; |
|||
printf("Deine Antwort (1, 2 oder 3): "); |
|||
scanf("%d", &benutzerAntwort); |
|||
|
|||
return (benutzerAntwort == frage.korrekteAntwort); |
|||
} |
|||
|
|||
int quiz() { |
|||
struct Frage fragen[3]; |
|||
fragen[0] = erstelleFrage("Was ist die Hauptstadt von Frankreich?", "Berlin", "Paris", "London", 2); |
|||
fragen[1] = erstelleFrage("Welches ist das groesste Saeugetier?", "Elefant", "Wal", "Giraffe", 2); |
|||
fragen[2] = erstelleFrage("Wer hat die Relativitaetstheorie entwickelt?", "Isaac Newton", "Albert Einstein", "Galileo Galilei", 2); |
|||
fragen[3] = erstelleFrage("Wer ist bundeskanzler?", "", "Thomas Mueller", "Olaf scholz", 2); |
|||
// Quiz starten |
|||
int punktzahl = 0; |
|||
int i; |
|||
for (i = 0; i < 4; i++) { |
|||
punktzahl +=zeigeFrage(fragen[i]); |
|||
|
|||
} |
|||
// Ergebnis anzeigen |
|||
printf("Deine Punktzahl: %d / %d\n", punktzahl, i); |
|||
|
|||
return 0; |
|||
} |
|||
|
@ -0,0 +1,7 @@ |
|||
#ifndef TOP_H |
|||
#define TOP_H |
|||
|
|||
|
|||
struct Frage erstelleFrage(char *text, char *antwort1, char *antwort2, char *antwort3, int korrekteAntwort); |
|||
|
|||
#endif //TOP_H |
@ -0,0 +1,25 @@ |
|||
#ifdef TEST |
|||
#include "unity.h" |
|||
#include "calculator.h" |
|||
|
|||
|
|||
void setUp(void){ |
|||
//Wenn Funktion Vorraussetzungen braucht |
|||
} |
|||
void tearDown(void){ |
|||
} |
|||
|
|||
|
|||
void test_factorial_4(void){ |
|||
/* arrange */ |
|||
double result; |
|||
double a = 4; |
|||
|
|||
/* act */ |
|||
result = factorial(a); |
|||
|
|||
/* assert */ |
|||
TEST_ASSERT_EQUAL_INT(24, result);//1 * 2 * 3 * 4 = 24 |
|||
} |
|||
|
|||
#endif |
@ -0,0 +1,40 @@ |
|||
#ifdef TEST |
|||
#include "unity.h" |
|||
#include "../../src/main/c/Calculator/calculator.h" |
|||
|
|||
|
|||
void setUp(void){ |
|||
//Wenn Funktion Vorraussetzungen braucht |
|||
} |
|||
void tearDown(void){ |
|||
} |
|||
|
|||
|
|||
void test_pow_N_N(void){ |
|||
/* arrange */ |
|||
double result; |
|||
double b = 3; |
|||
double a = 3; |
|||
|
|||
/* act */ |
|||
result = pow(a, b); |
|||
|
|||
/* assert */ |
|||
TEST_ASSERT_EQUAL_INT(27, result);//3 * 3 * 3 = 27 |
|||
} |
|||
|
|||
void test_pow_Z_N(void){ |
|||
/* arrange */ |
|||
double result; |
|||
double b = 3; |
|||
double a = -3; |
|||
|
|||
/* act */ |
|||
result = pow(a, b); |
|||
|
|||
/* assert */ |
|||
TEST_ASSERT_EQUAL_INT(-27, result);//3 * 3 * 3 = 27 |
|||
} |
|||
|
|||
|
|||
#endif // TEST |
Write
Preview
Loading…
Cancel
Save
Reference in new issue