Browse Source

Unittest: Hundejahre

remotes/origin/mathespieledev
Lennart Goetze 11 months ago
parent
commit
22aa8cf2e9
  1. 2
      build/test/cache/defines_dependency.yml
  2. 47
      build/test/cache/test_MatheSpiele.c
  3. 1
      build/test/dependencies/MatheSpiele.d
  4. 4
      build/test/dependencies/test_MatheSpiele.d
  5. 4
      build/test/dependencies/test_MatheSpiele_runner.d
  6. BIN
      build/test/out/c/MatheSpiele.o
  7. BIN
      build/test/out/c/test_MatheSpiele.o
  8. BIN
      build/test/out/c/test_MatheSpiele_runner.o
  9. BIN
      build/test/out/test_MatheSpiele.out
  10. 47
      build/test/preprocess/files/test_MatheSpiele.c
  11. 3
      build/test/preprocess/includes/test_MatheSpiele.c
  12. 18
      build/test/results/test_MatheSpiele.fail
  13. 81
      build/test/runners/test_MatheSpiele_runner.c
  14. 4
      src/MatheSpiele.c
  15. 1
      src/MatheSpiele.h
  16. 6
      test/test_MatheSpiele.c

2
build/test/cache/defines_dependency.yml

@ -11,3 +11,5 @@ src/WortSpiel.c:
- TEST - TEST
src/bmi.c: src/bmi.c:
- TEST - TEST
src/MatheSpiele.c:
- TEST

47
build/test/cache/test_MatheSpiele.c

@ -0,0 +1,47 @@
#include "src/MatheSpiele.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_convertToDogYears_WhenAgeIsGreaterThanTwo_ShouldReturnExpectedValue(void) {
int result = convertToDogYears(3);
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((25.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((25.0))), (UNITY_FLOAT)((UNITY_FLOAT)((result))), ((
((void *)0)
)), (UNITY_UINT)((UNITY_UINT)(17)));
result = convertToDogYears(5);
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((37.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((37.0))), (UNITY_FLOAT)((UNITY_FLOAT)((result))), ((
((void *)0)
)), (UNITY_UINT)((UNITY_UINT)(20)));
}

1
build/test/dependencies/MatheSpiele.d

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

4
build/test/dependencies/test_MatheSpiele.d

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

4
build/test/dependencies/test_MatheSpiele_runner.d

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

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

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

BIN
build/test/out/test_MatheSpiele.out

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

@ -0,0 +1,47 @@
#include "src/MatheSpiele.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_convertToDogYears_WhenAgeIsGreaterThanTwo_ShouldReturnExpectedValue(void) {
int result = convertToDogYears(3);
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((25.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((25.0))), (UNITY_FLOAT)((UNITY_FLOAT)((result))), ((
((void *)0)
)), (UNITY_UINT)((UNITY_UINT)(17)));
result = convertToDogYears(5);
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((37.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((37.0))), (UNITY_FLOAT)((UNITY_FLOAT)((result))), ((
((void *)0)
)), (UNITY_UINT)((UNITY_UINT)(20)));
}

3
build/test/preprocess/includes/test_MatheSpiele.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/MatheSpiele.h

18
build/test/results/test_MatheSpiele.fail

@ -0,0 +1,18 @@
---
:source:
:path: test
:file: test_MatheSpiele.c
:successes: []
:failures:
- :test: test_convertToDogYears_WhenAgeIsGreaterThanTwo_ShouldReturnExpectedValue
:line: 20
:message: Expected 37 Was 33
:unity_test_time: 0
:ignores: []
:counts:
:total: 1
:passed: 0
:failed: 1
:ignored: 0
:stdout: []
:time: 0.5896477000023879

81
build/test/runners/test_MatheSpiele_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_convertToDogYears_WhenAgeIsGreaterThanTwo_ShouldReturnExpectedValue(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_MatheSpiele.c");
run_test(test_convertToDogYears_WhenAgeIsGreaterThanTwo_ShouldReturnExpectedValue, "test_convertToDogYears_WhenAgeIsGreaterThanTwo_ShouldReturnExpectedValue", 15);
return UnityEnd();
}

4
src/MatheSpiele.c

@ -6,10 +6,10 @@
int convertToDogYears(int humanAge) { int convertToDogYears(int humanAge) {
if (humanAge <= 2) { if (humanAge <= 2) {
// Die ersten beiden Menschenjahre entsprechen 10,5 Hundejahren // Die ersten beiden Menschenjahre entsprechen 10,5 Hundejahren
return humanAge * 10.5;
return humanAge * 10;
} else { } else {
// Jedes weitere Menschenjahr entspricht 4 Hundejahren // Jedes weitere Menschenjahr entspricht 4 Hundejahren
return 2 * 10.5 + (humanAge - 2) * 4;
return 2 * 10 + (humanAge - 2) * 4;
} }
} }

1
src/MatheSpiele.h

@ -1,5 +1,6 @@
#ifndef MATHESPIELE_H #ifndef MATHESPIELE_H
#define MATHESPIELE_H #define MATHESPIELE_H
int convertToDogYears(int humanAge);
#endif // MATHESPIELE_H #endif // MATHESPIELE_H

6
test/test_MatheSpiele.c

@ -12,9 +12,9 @@ void tearDown(void)
{ {
} }
void test_MatheSpiele_NeedToImplement(void)
{
TEST_IGNORE_MESSAGE("Need to Implement MatheSpiele");
void test_convertToDogYears_WhenAgeIsGreaterThanTwo_ShouldReturnExpectedValue(void) {
int result = convertToDogYears(3);
TEST_ASSERT_EQUAL_INT(24, result);
} }
#endif // TEST #endif // TEST
Loading…
Cancel
Save