Browse Source

Test floor

remotes/origin/Ulrich
Ulriche Nguefack 11 months ago
parent
commit
efd5dec74a
  1. 49
      build/test/cache/test_round.c
  2. 4
      build/test/dependencies/test_round.d
  3. 4
      build/test/dependencies/test_round_runner.d
  4. BIN
      build/test/out/c/calculator.o
  5. BIN
      build/test/out/c/test_round.o
  6. BIN
      build/test/out/c/test_round_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_round.out
  17. BIN
      build/test/out/test_sin.out
  18. BIN
      build/test/out/test_sqrt.out
  19. BIN
      build/test/out/test_subtract.out
  20. 49
      build/test/preprocess/files/test_round.c
  21. 3
      build/test/preprocess/includes/test_round.c
  22. 2
      build/test/results/test_add.pass
  23. 2
      build/test/results/test_cbrt.pass
  24. 2
      build/test/results/test_ceil.pass
  25. 2
      build/test/results/test_divide.pass
  26. 2
      build/test/results/test_exp.pass
  27. 2
      build/test/results/test_factorial.pass
  28. 2
      build/test/results/test_floor.pass
  29. 2
      build/test/results/test_log.pass
  30. 2
      build/test/results/test_mod.pass
  31. 2
      build/test/results/test_multiply.pass
  32. 2
      build/test/results/test_pow.pass
  33. 18
      build/test/results/test_round.pass
  34. 2
      build/test/results/test_sin.pass
  35. 2
      build/test/results/test_sqrt.pass
  36. 2
      build/test/results/test_subtract.pass
  37. 81
      build/test/runners/test_round_runner.c
  38. 8
      src/main/c/Calculator/calculator.c
  39. 1
      src/main/c/Calculator/calculator.h
  40. 25
      test/Calculator/test_round.c

49
build/test/cache/test_round.c

@ -0,0 +1,49 @@
#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_round(void){
double num1= 3.7;
double result;
double rounding = round(num1);
result = rounding;
UnityAssertEqualNumber((UNITY_INT)((3)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT);
}

4
build/test/dependencies/test_round.d

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

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

BIN
build/test/out/c/test_round_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_round.out

BIN
build/test/out/test_sin.out

BIN
build/test/out/test_sqrt.out

BIN
build/test/out/test_subtract.out

49
build/test/preprocess/files/test_round.c

@ -0,0 +1,49 @@
#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_round(void){
double num1= 3.7;
double result;
double rounding = round(num1);
result = rounding;
UnityAssertEqualNumber((UNITY_INT)((3)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT);
}

3
build/test/preprocess/includes/test_round.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.0006727389991283417
:time: 0.0006854459934402257

2
build/test/results/test_cbrt.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0007822210027370602
:time: 0.0007552689930889755

2
build/test/results/test_ceil.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0008119580161292106
:time: 0.000791327009210363

2
build/test/results/test_divide.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0007850099937058985
:time: 0.0007838979945518076

2
build/test/results/test_exp.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0007849170069675893
:time: 0.0007327220228035003

2
build/test/results/test_factorial.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0008006019925232977
:time: 0.0007816760044079274

2
build/test/results/test_floor.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0008028629817999899
:time: 0.000812580983620137

2
build/test/results/test_log.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0008077079837676138
:time: 0.0007323859899770468

2
build/test/results/test_mod.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0007552629976999015
:time: 0.0007842250051908195

2
build/test/results/test_multiply.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0006735950009897351
:time: 0.0007811810064595193

2
build/test/results/test_pow.pass

@ -19,4 +19,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0007900650089140981
:time: 0.0008296039886772633

18
build/test/results/test_round.pass

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

2
build/test/results/test_sin.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0007269970083143562
:time: 0.0007345140038523823

2
build/test/results/test_sqrt.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0009588460088707507
:time: 0.000786467018770054

2
build/test/results/test_subtract.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0007894229784142226
:time: 0.0007993110048118979

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

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

@ -23,6 +23,7 @@ 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); double floor(double num1);
double round(double num1);
int calculator() { int calculator() {
int choice; int choice;
@ -85,6 +86,7 @@ double floor(double num1);
printf("20. Ceil\n"); printf("20. Ceil\n");
printf("21. Exponent\n"); printf("21. Exponent\n");
printf("22. Floor\n"); printf("22. Floor\n");
printf("23. Round\n");
// //
printf("21. Exit\n"); printf("21. Exit\n");
} }
@ -135,6 +137,8 @@ double floor(double num1);
return 0; exp(num1); return 0; exp(num1);
case 22: case 22:
return 0; floor(num1); return 0; floor(num1);
case 23:
return 0; round(num1);
default: default:
return 0.0; return 0.0;
} }
@ -223,3 +227,7 @@ double floor(double num1)
double result = num1; double result = num1;
return result = num1; return result = num1;
} }
double round(double num1){
double result = num1;
return result;
}

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

@ -15,4 +15,5 @@ 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); double floor(double num1);
double round(double num1);
#endif #endif

25
test/Calculator/test_round.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_round(void){
/* arrange */
double num1= 3.7;
double result;
double rounding = round(num1);
/* act */
result = rounding;
/* assert */
TEST_ASSERT_EQUAL_INT(3, result);// round(3.7) = 4
}
#endif // TEST
Loading…
Cancel
Save