Browse Source

Unittest: determineWinner

remotes/origin/bmidev
Lennart Goetze 11 months ago
parent
commit
a50c84c645
  1. 2
      build/test/cache/defines_dependency.yml
  2. 43
      build/test/cache/test_SchereSteinPapier.c
  3. 2
      build/test/dependencies/SchereSteinPapier.d
  4. 4
      build/test/dependencies/test_SchereSteinPapier.d
  5. 4
      build/test/dependencies/test_SchereSteinPapier_runner.d
  6. BIN
      build/test/out/c/SchereSteinPapier.o
  7. BIN
      build/test/out/c/test_SchereSteinPapier.o
  8. BIN
      build/test/out/c/test_SchereSteinPapier_runner.o
  9. BIN
      build/test/out/test_SchereSteinPapier.out
  10. BIN
      build/test/out/test_ageinseconds.out
  11. BIN
      build/test/out/test_minirechner.out
  12. BIN
      build/test/out/test_zahlenraten.out
  13. 43
      build/test/preprocess/files/test_SchereSteinPapier.c
  14. 3
      build/test/preprocess/includes/test_SchereSteinPapier.c
  15. 18
      build/test/results/test_SchereSteinPapier.pass
  16. 2
      build/test/results/test_ageinseconds.pass
  17. 2
      build/test/results/test_minirechner.pass
  18. 2
      build/test/results/test_zahlenraten.pass
  19. 81
      build/test/runners/test_SchereSteinPapier_runner.c
  20. 1
      src/SchereSteinPapier.h
  21. 22
      test/test_SchereSteinPapier.c

2
build/test/cache/defines_dependency.yml

@ -5,3 +5,5 @@ src/minirechner.c:
- TEST
src/zahlenraten.c:
- TEST
src/SchereSteinPapier.c:
- TEST

43
build/test/cache/test_SchereSteinPapier.c

@ -0,0 +1,43 @@
#include "src/SchereSteinPapier.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 test_Scheresteinpapier_generateRandom(void) {
srand(42);
for (int i = 0; i < 100; ++i) {
int result = generateRandom();
do {if ((result >= 0 && result <= 2)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(21)));}} while(0);
}
}

2
build/test/dependencies/SchereSteinPapier.d

@ -0,0 +1,2 @@
build/test/out/c/SchereSteinPapier.o: src/SchereSteinPapier.c \
src/SchereSteinPapier.h

4
build/test/dependencies/test_SchereSteinPapier.d

@ -0,0 +1,4 @@
build/test/out/c/test_SchereSteinPapier.o: test/test_SchereSteinPapier.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/SchereSteinPapier.h

4
build/test/dependencies/test_SchereSteinPapier_runner.d

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

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

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

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

BIN
build/test/out/test_SchereSteinPapier.out

BIN
build/test/out/test_ageinseconds.out

BIN
build/test/out/test_minirechner.out

BIN
build/test/out/test_zahlenraten.out

43
build/test/preprocess/files/test_SchereSteinPapier.c

@ -0,0 +1,43 @@
#include "src/SchereSteinPapier.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 test_Scheresteinpapier_generateRandom(void) {
srand(42);
for (int i = 0; i < 100; ++i) {
int result = generateRandom();
do {if ((result >= 0 && result <= 2)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(21)));}} while(0);
}
}

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

@ -0,0 +1,3 @@
---
- C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h
- src/SchereSteinPapier.h

18
build/test/results/test_SchereSteinPapier.pass

@ -0,0 +1,18 @@
---
:source:
:path: test
:file: test_SchereSteinPapier.c
:successes:
- :test: test_Scheresteinpapier_generateRandom
:line: 15
:message: ''
:unity_test_time: 0
:failures: []
:ignores: []
:counts:
:total: 1
:passed: 1
:failed: 0
:ignored: 0
:stdout: []
:time: 0.03652950000105193

2
build/test/results/test_ageinseconds.pass

@ -23,4 +23,4 @@
:failed: 0
:ignored: 0
:stdout: []
:time: 0.8361497999994754
:time: 0.03658220000033907

2
build/test/results/test_minirechner.pass

@ -83,4 +83,4 @@
:failed: 0
:ignored: 0
:stdout: []
:time: 0.33068490000005113
:time: 0.03659530000004452

2
build/test/results/test_zahlenraten.pass

@ -15,4 +15,4 @@
:failed: 0
:ignored: 0
:stdout: []
:time: 0.31757349999952567
:time: 0.03663650000089547

81
build/test/runners/test_SchereSteinPapier_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_Scheresteinpapier_generateRandom(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_SchereSteinPapier.c");
run_test(test_Scheresteinpapier_generateRandom, "test_Scheresteinpapier_generateRandom", 15);
return UnityEnd();
}

1
src/SchereSteinPapier.h

@ -2,5 +2,6 @@
#define SCHERESTEINPAPIER_H
int generateRandom();
int determineWinner(int spielerWahl, int computerWahl);
#endif // SCHERESTEINPAPIER_H

22
test/test_SchereSteinPapier.c

@ -22,4 +22,26 @@ void test_Scheresteinpapier_generateRandom(void) {
}
}
void test_Scheresteinpapier_determineWinner(void) {
for (int spieler = 0; spieler <= 2; ++spieler) {
for (int computer = 0; computer <= 2; ++computer) {
int result = determineWinner(spieler, computer);
if ((spieler == 0 && computer == 2) ||
(spieler == 1 && computer == 0) ||
(spieler == 2 && computer == 1)) {
TEST_ASSERT_EQUAL(1, result); // Spieler gewinnt
}
else if (spieler == computer) {
TEST_ASSERT_EQUAL(0, result); // Unentschieden
}
else {
TEST_ASSERT_EQUAL(-1, result); // Computer gewinnt
}
}
}
}
#endif // TEST
Loading…
Cancel
Save