Browse Source

Test floor

remotes/origin/Ulrich
Ulriche Nguefack 11 months ago
parent
commit
023cb11a6d
  1. 47
      build/test/cache/test_floor.c
  2. 4
      build/test/dependencies/test_floor.d
  3. 4
      build/test/dependencies/test_floor_runner.d
  4. BIN
      build/test/out/c/calculator.o
  5. BIN
      build/test/out/c/test_floor.o
  6. BIN
      build/test/out/c/test_floor_runner.o
  7. BIN
      build/test/out/test_cbrt.out
  8. BIN
      build/test/out/test_ceil.out
  9. BIN
      build/test/out/test_divide.out
  10. BIN
      build/test/out/test_exp.out
  11. BIN
      build/test/out/test_factorial.out
  12. BIN
      build/test/out/test_floor.out
  13. BIN
      build/test/out/test_log.out
  14. BIN
      build/test/out/test_mod.out
  15. BIN
      build/test/out/test_pow.out
  16. BIN
      build/test/out/test_sin.out
  17. BIN
      build/test/out/test_sqrt.out
  18. BIN
      build/test/out/test_subtract.out
  19. 47
      build/test/preprocess/files/test_floor.c
  20. 3
      build/test/preprocess/includes/test_floor.c
  21. 2
      build/test/results/test_add.pass
  22. 2
      build/test/results/test_cbrt.pass
  23. 2
      build/test/results/test_ceil.pass
  24. 2
      build/test/results/test_divide.pass
  25. 2
      build/test/results/test_exp.pass
  26. 2
      build/test/results/test_factorial.pass
  27. 18
      build/test/results/test_floor.pass
  28. 2
      build/test/results/test_log.pass
  29. 2
      build/test/results/test_mod.pass
  30. 2
      build/test/results/test_multiply.pass
  31. 2
      build/test/results/test_pow.pass
  32. 2
      build/test/results/test_sin.pass
  33. 2
      build/test/results/test_sqrt.pass
  34. 2
      build/test/results/test_subtract.pass
  35. 81
      build/test/runners/test_floor_runner.c
  36. 10
      src/main/c/Calculator/calculator.c
  37. 1
      src/main/c/Calculator/calculator.h
  38. 25
      test/Calculator/test_floor.c

47
build/test/cache/test_floor.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_floor(void){
double result;
double num1 = 7.12;
result = floor(num1);
UnityAssertEqualNumber((UNITY_INT)((7)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(22), UNITY_DISPLAY_STYLE_INT);
}

4
build/test/dependencies/test_floor.d

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

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

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

BIN
build/test/out/test_cbrt.out

BIN
build/test/out/test_ceil.out

BIN
build/test/out/test_divide.out

BIN
build/test/out/test_exp.out

BIN
build/test/out/test_factorial.out

BIN
build/test/out/test_floor.out

BIN
build/test/out/test_log.out

BIN
build/test/out/test_mod.out

BIN
build/test/out/test_pow.out

BIN
build/test/out/test_sin.out

BIN
build/test/out/test_sqrt.out

BIN
build/test/out/test_subtract.out

47
build/test/preprocess/files/test_floor.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_floor(void){
double result;
double num1 = 7.12;
result = floor(num1);
UnityAssertEqualNumber((UNITY_INT)((7)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(22), UNITY_DISPLAY_STYLE_INT);
}

3
build/test/preprocess/includes/test_floor.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_add.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0018099159933626652
:time: 0.0006380429840646684

2
build/test/results/test_cbrt.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.003295011993031949
:time: 0.00398757797665894

2
build/test/results/test_ceil.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0024341249954886734
:time: 0.0025626359856687486

2
build/test/results/test_divide.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0008051539771258831
:time: 0.0024843739811331034

2
build/test/results/test_exp.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0007799550076015294
:time: 0.006211458996403962

2
build/test/results/test_factorial.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0007686699973419309
:time: 0.002500028000213206

18
build/test/results/test_floor.pass

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

2
build/test/results/test_log.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0007523740059696138
:time: 0.006268427998293191

2
build/test/results/test_mod.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0007482499931938946
:time: 0.0073656839958857745

2
build/test/results/test_multiply.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0014812659937888384
:time: 0.00431214299169369

2
build/test/results/test_pow.pass

@ -19,4 +19,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0008077819948084652
:time: 0.006361996987834573

2
build/test/results/test_sin.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0007749740034341812
:time: 0.005958255002042279

2
build/test/results/test_sqrt.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0007332070090342313
:time: 0.006205737998243421

2
build/test/results/test_subtract.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0008089379989542067
:time: 0.00599369901465252

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

10
src/main/c/Calculator/calculator.c

@ -22,7 +22,7 @@ int add (int num1, int num2);
int subtract(int num1, int num2); int subtract(int num1, int num2);
double exp(double num1); double exp(double num1);
double ceil(double num1); double ceil(double num1);
double floor(double num1);
int calculator() { int calculator() {
int choice; int choice;
@ -84,6 +84,7 @@ double ceil(double num1);
printf("19. Combination\n"); printf("19. Combination\n");
printf("20. Ceil\n"); printf("20. Ceil\n");
printf("21. Exponent\n"); printf("21. Exponent\n");
printf("22. Floor\n");
// //
printf("21. Exit\n"); printf("21. Exit\n");
} }
@ -132,6 +133,8 @@ double ceil(double num1);
return 0; ceil(num1); return 0; ceil(num1);
case 21: case 21:
return 0; exp(num1); return 0; exp(num1);
case 22:
return 0; floor(num1);
default: default:
return 0.0; return 0.0;
} }
@ -215,3 +218,8 @@ double ceil(double num1){
double result = num1; double result = num1;
return result; return result;
} }
double floor(double num1)
{
double result = num1;
return result = num1;
}

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

@ -14,4 +14,5 @@ int add(int num1 ,int num2);
int subtract(int num1, int num2); int subtract(int num1, int num2);
double exp(double num1); double exp(double num1);
double ceil(double num1); double ceil(double num1);
double floor(double num1);
#endif #endif

25
test/Calculator/test_floor.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_floor(void){
/* arrange */
double result;
double num1 = 7.12;
/* act */
result = floor(num1);
/* assert */
TEST_ASSERT_EQUAL_INT(7, result);// floor(7.12) = 7
}
#endif // TEST
Loading…
Cancel
Save