Browse Source

Merge branch 'Ulrich' into 'main'

Ulrich

See merge request pmuw_projekt/pmuw_projekt_notebinder!41
remotes/origin/Saba
fdai7899 11 months ago
parent
commit
8ecb13100a
  1. 0
      And
  2. 0
      Shell
  3. 0
      build/release/dependencies/force_build
  4. 1
      build/release/dependencies/top.d
  5. BIN
      build/release/out/c/top.o
  6. 4
      build/test/cache/defines_dependency.yml
  7. 12
      build/test/cache/input.yml
  8. 79
      build/test/cache/test_add.c
  9. 47
      build/test/cache/test_factorial.c
  10. 79
      build/test/cache/test_pow.c
  11. 2
      build/test/cache/test_template.c
  12. 1
      build/test/dependencies/calculator.d
  13. 0
      build/test/dependencies/force_build
  14. 4
      build/test/dependencies/test_add.d
  15. 3
      build/test/dependencies/test_add_runner.d
  16. 4
      build/test/dependencies/test_factorial.d
  17. 4
      build/test/dependencies/test_factorial_runner.d
  18. 4
      build/test/dependencies/test_pow.d
  19. 3
      build/test/dependencies/test_pow_runner.d
  20. 4
      build/test/dependencies/test_template_runner.d
  21. BIN
      build/test/out/c/calculator.o
  22. BIN
      build/test/out/c/test_add.o
  23. BIN
      build/test/out/c/test_add_runner.o
  24. BIN
      build/test/out/c/test_factorial.o
  25. BIN
      build/test/out/c/test_factorial_runner.o
  26. BIN
      build/test/out/c/test_pow.o
  27. BIN
      build/test/out/c/test_pow_runner.o
  28. BIN
      build/test/out/c/test_template_runner.o
  29. BIN
      build/test/out/test_add.out
  30. BIN
      build/test/out/test_factorial.out
  31. BIN
      build/test/out/test_pow.out
  32. BIN
      build/test/out/test_template.out
  33. 79
      build/test/preprocess/files/test_add.c
  34. 47
      build/test/preprocess/files/test_factorial.c
  35. 79
      build/test/preprocess/files/test_pow.c
  36. 2
      build/test/preprocess/files/test_template.c
  37. 3
      build/test/preprocess/includes/test_add.c
  38. 3
      build/test/preprocess/includes/test_factorial.c
  39. 3
      build/test/preprocess/includes/test_pow.c
  40. 2
      build/test/preprocess/includes/test_template.c
  41. 22
      build/test/results/test_add.pass
  42. 18
      build/test/results/test_factorial.pass
  43. 22
      build/test/results/test_pow.pass
  44. 4
      build/test/results/test_template.pass
  45. 83
      build/test/runners/test_add_runner.c
  46. 81
      build/test/runners/test_factorial_runner.c
  47. 83
      build/test/runners/test_pow_runner.c
  48. 158
      src/main/c/Calculator/calculator.c
  49. BIN
      src/main/c/Calculator/calculator.exe
  50. 8
      src/main/c/Calculator/calculator.h
  51. 29
      src/main/c/Quiz/Quiz_2.c
  52. 6
      src/main/c/Quiz/Quiz_2.h
  53. 57
      src/main/c/Quiz/top.c
  54. 7
      src/main/c/Quiz/top.h
  55. 8
      src/main/c/main.c
  56. 1
      team.md
  57. 25
      test/Calculator/test_factorial.c
  58. 40
      test/Calculator/test_pow.c

0
And

0
Shell

0
build/release/dependencies/force_build

1
build/release/dependencies/top.d

@ -0,0 +1 @@
build/release/out/c/top.o: src/main/c/Quiz/top.c

BIN
build/release/out/c/top.o

4
build/test/cache/defines_dependency.yml

@ -1,6 +1,9 @@
--- ---
src/main/c/Template/game100.c: src/main/c/Template/game100.c:
- TEST - TEST
<<<<<<< HEAD
src/main/c/Calculator/calculator.c:
=======
src/main/c/Snake/snake_start.c: src/main/c/Snake/snake_start.c:
- TEST - TEST
src/main/c/Snake/get_character.c: src/main/c/Snake/get_character.c:
@ -10,4 +13,5 @@ src/main/c/Minesweeper/minesweeper_start.c:
src/main/c/GameTic_Tac_Toe/tictactoe.c: src/main/c/GameTic_Tac_Toe/tictactoe.c:
- TEST - TEST
src/main/c/Pong/pong.c: src/main/c/Pong/pong.c:
>>>>>>> 2acead7a056f156a3c7129d740f7d5585fbc805f
- TEST - TEST

12
build/test/cache/input.yml

@ -77,10 +77,10 @@
:testfail: ".fail" :testfail: ".fail"
:dependencies: ".d" :dependencies: ".d"
:unity: :unity:
:vendor_path: "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor"
:vendor_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor"
:defines: [] :defines: []
:cmock: :cmock:
:vendor_path: "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor"
:vendor_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor"
:defines: [] :defines: []
:includes: [] :includes: []
:mock_prefix: mock_ :mock_prefix: mock_
@ -99,7 +99,7 @@
:verbosity: 3 :verbosity: 3
:unity_helper: false :unity_helper: false
:cexception: :cexception:
:vendor_path: "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor"
:vendor_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor"
:defines: [] :defines: []
:test_runner: :test_runner:
:includes: [] :includes: []
@ -257,13 +257,13 @@
:arguments: [] :arguments: []
:plugins: :plugins:
:load_paths: :load_paths:
- "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/lib/../plugins"
- "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins"
:enabled: :enabled:
- stdout_pretty_tests_report - stdout_pretty_tests_report
- module_generator - module_generator
:display_raw_test_results: false :display_raw_test_results: false
:stdout_pretty_tests_report_path: "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/lib/../plugins/stdout_pretty_tests_report"
:module_generator_path: "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/lib/../plugins/module_generator"
:stdout_pretty_tests_report_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/stdout_pretty_tests_report"
:module_generator_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/module_generator"
:gcov: :gcov:
:reports: :reports:
- HtmlDetailed - HtmlDetailed

79
build/test/cache/test_add.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);
}

47
build/test/cache/test_factorial.c

@ -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);
}

79
build/test/cache/test_pow.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);
}

2
build/test/cache/test_template.c

@ -1,5 +1,5 @@
#include "src/main/c/Template/game100.h" #include "src/main/c/Template/game100.h"
#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"
#include "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"

1
build/test/dependencies/calculator.d

@ -0,0 +1 @@
build/test/out/c/calculator.o: src/main/c/Calculator/calculator.c

0
build/test/dependencies/force_build

4
build/test/dependencies/test_add.d

@ -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

3
build/test/dependencies/test_add_runner.d

@ -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

4
build/test/dependencies/test_factorial.d

@ -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

4
build/test/dependencies/test_factorial_runner.d

@ -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

4
build/test/dependencies/test_pow.d

@ -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

3
build/test/dependencies/test_pow_runner.d

@ -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

4
build/test/dependencies/test_template_runner.d

@ -1,4 +1,4 @@
build/test/out/c/test_template_runner.o: \ build/test/out/c/test_template_runner.o: \
build/test/runners/test_template_runner.c \ 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

BIN
build/test/out/c/calculator.o

BIN
build/test/out/c/test_add.o

BIN
build/test/out/c/test_add_runner.o

BIN
build/test/out/c/test_factorial.o

BIN
build/test/out/c/test_factorial_runner.o

BIN
build/test/out/c/test_pow.o

BIN
build/test/out/c/test_pow_runner.o

BIN
build/test/out/c/test_template_runner.o

BIN
build/test/out/test_add.out

BIN
build/test/out/test_factorial.out

BIN
build/test/out/test_pow.out

BIN
build/test/out/test_template.out

79
build/test/preprocess/files/test_add.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);
}

47
build/test/preprocess/files/test_factorial.c

@ -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);
}

79
build/test/preprocess/files/test_pow.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);
}

2
build/test/preprocess/files/test_template.c

@ -1,5 +1,5 @@
#include "src/main/c/Template/game100.h" #include "src/main/c/Template/game100.h"
#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"
#include "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"

3
build/test/preprocess/includes/test_add.c

@ -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

3
build/test/preprocess/includes/test_factorial.c

@ -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

3
build/test/preprocess/includes/test_pow.c

@ -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

2
build/test/preprocess/includes/test_template.c

@ -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 - src/main/c/Template/game100.h

22
build/test/results/test_add.pass

@ -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

18
build/test/results/test_factorial.pass

@ -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

22
build/test/results/test_pow.pass

@ -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

4
build/test/results/test_template.pass

@ -19,4 +19,8 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
<<<<<<< HEAD
:time: 0.002953332004835829
=======
:time: 0.001957057000254281 :time: 0.001957057000254281
>>>>>>> 2acead7a056f156a3c7129d740f7d5585fbc805f

83
build/test/runners/test_add_runner.c

@ -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();
}

81
build/test/runners/test_factorial_runner.c

@ -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();
}

83
build/test/runners/test_pow_runner.c

@ -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();
}

158
src/main/c/Calculator/calculator.c

@ -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;
}

BIN
src/main/c/Calculator/calculator.exe

8
src/main/c/Calculator/calculator.h

@ -0,0 +1,8 @@
#ifndef CALCULATOR_H
#define CALCULATOR_H
int calculator();
double pow(double num1, double num2);
double factorial(double num);
#endif

29
src/main/c/Quiz/Quiz_2.c

@ -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;
}

6
src/main/c/Quiz/Quiz_2.h

@ -0,0 +1,6 @@
#ifndef QUIZ_2_H
#define QUIZ_2_H
void quiz_2();
#endif //QUIZ_2_H

57
src/main/c/Quiz/top.c

@ -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;
}

7
src/main/c/Quiz/top.h

@ -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

8
src/main/c/main.c

@ -2,7 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include "Quiz/top.h"
#include "GameTic_Tac_Toe/tictactoe.h" #include "GameTic_Tac_Toe/tictactoe.h"
#include "Snake/snake_start.h" #include "Snake/snake_start.h"
#include "Minesweeper/minesweeper_start.h" #include "Minesweeper/minesweeper_start.h"
@ -23,7 +23,8 @@ int main(){
printf("\t2.Pong starten\n"); printf("\t2.Pong starten\n");
printf("\t3.Snake starten\n"); printf("\t3.Snake starten\n");
printf("\t4.tic_tac_toe starten\n"); printf("\t4.tic_tac_toe starten\n");
printf("\t5.battleship starten\n")
printf("\t5.battleship starten\n");
printf("\t6.Quiz starten\n");
printf("\t7.Minesweeper starten\n"); printf("\t7.Minesweeper starten\n");
printf("\t10.Exit\n"); printf("\t10.Exit\n");
@ -46,6 +47,9 @@ int main(){
case 5: case 5:
start_battleship(); start_battleship();
break; break;
case 6:
quiz();
break;
case 7: case 7:
minesweeper_start(); minesweeper_start();
break; break;

1
team.md

@ -4,4 +4,5 @@
- Ariana Ginju, fdai7775 - Ariana Ginju, fdai7775
- fdai7775, fdai7775 - fdai7775, fdai7775
- Saba Fazlali, fdai7875 - Saba Fazlali, fdai7875
- Ulriche Nguefack, fdai7899
- Nina Gärtner, fdai7729 - Nina Gärtner, fdai7729

25
test/Calculator/test_factorial.c

@ -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

40
test/Calculator/test_pow.c

@ -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
Loading…
Cancel
Save