Browse Source

Test mod

remotes/origin/Ulrich
Ulriche Nguefack 11 months ago
parent
commit
abe0a3ae61
  1. 47
      build/test/cache/test_mod.c
  2. 4
      build/test/dependencies/test_mod.d
  3. 3
      build/test/dependencies/test_mod_runner.d
  4. BIN
      build/test/out/c/calculator.o
  5. BIN
      build/test/out/c/test_mod.o
  6. BIN
      build/test/out/c/test_mod_runner.o
  7. BIN
      build/test/out/test_factorial.out
  8. BIN
      build/test/out/test_mod.out
  9. BIN
      build/test/out/test_pow.out
  10. 47
      build/test/preprocess/files/test_mod.c
  11. 3
      build/test/preprocess/includes/test_mod.c
  12. 2
      build/test/results/test_factorial.pass
  13. 18
      build/test/results/test_mod.pass
  14. 2
      build/test/results/test_pow.pass
  15. 81
      build/test/runners/test_mod_runner.c
  16. 8
      src/main/c/Calculator/calculator.c
  17. 1
      src/main/c/Calculator/calculator.h
  18. 26
      test/Calculator/test_mod.c

47
build/test/cache/test_mod.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_mod(void){
int result;
result = mod(10, 5);
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(22), UNITY_DISPLAY_STYLE_INT);
}

4
build/test/dependencies/test_mod.d

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

3
build/test/dependencies/test_mod_runner.d

@ -0,0 +1,3 @@
build/test/out/c/test_mod_runner.o: build/test/runners/test_mod_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

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

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

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

BIN
build/test/out/test_factorial.out

BIN
build/test/out/test_mod.out

BIN
build/test/out/test_pow.out

47
build/test/preprocess/files/test_mod.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_mod(void){
int result;
result = mod(10, 5);
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(22), UNITY_DISPLAY_STYLE_INT);
}

3
build/test/preprocess/includes/test_mod.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

2
build/test/results/test_factorial.pass

@ -15,4 +15,4 @@
:failed: 0
:ignored: 0
:stdout: []
:time: 0.00677925901254639
:time: 0.006395165983121842

18
build/test/results/test_mod.pass

@ -0,0 +1,18 @@
---
:source:
:path: test/Calculator
:file: test_mod.c
:successes:
- :test: test_mod
:line: 13
:message: ''
:unity_test_time: 0
:failures: []
:ignores: []
:counts:
:total: 1
:passed: 1
:failed: 0
:ignored: 0
:stdout: []
:time: 0.006040317006409168

2
build/test/results/test_pow.pass

@ -19,4 +19,4 @@
:failed: 0
:ignored: 0
:stdout: []
:time: 0.006241032999241725
:time: 0.005650753009831533

81
build/test/runners/test_mod_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_mod(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_mod.c");
run_test(test_mod, "test_mod", 13);
return UnityEnd();
}

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

@ -1,4 +1,5 @@
#include <stdio.h>
#include <math.h>
#define M_PI 3.14159265358979323
@ -11,6 +12,7 @@ double factorial(double num);
double permutation(int n, int r);
double combination(int n, int r);
double pow(double num1, double num2);
int mod(int num1,int num2);
int calculator() {
int choice;
@ -85,7 +87,7 @@ double pow(double num1, double num2);
case 5:
return pow(num1, num2);
case 6:
return 0;// fmod(num1, num2);
return 0; fmod(num1, num2);
case 7:
return 0;// log(num1);
case 8:
@ -156,3 +158,7 @@ double pow(double num1, double num2){
}
return product;
}
int mod(int num1, int num2){
int result = num1%num2;
return result;
}

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

@ -4,5 +4,6 @@
int calculator();
double pow(double num1, double num2);
double factorial(double num);
int mod(int num1, int num2);
#endif

26
test/Calculator/test_mod.c

@ -0,0 +1,26 @@
#ifdef TEST
#include "unity.h"
#include "calculator.h"
#include "math.h"
void setUp(void){
//Wenn Funktion Vorraussetzungen braucht
}
void tearDown(void){
}
void test_mod(void){
/* arrange */
int result;
/* act */
result = mod(10, 5);
/* assert */
TEST_ASSERT_EQUAL_INT(0, result);//10%5
}
#endif // TEST
Loading…
Cancel
Save