Browse Source

Test logarithm 10

remotes/origin/Ulrich
Ulriche Nguefack 11 months ago
parent
commit
cd7ba3200c
  1. 35
      build/test/cache/test_fmax.c
  2. 49
      build/test/cache/test_log10.c
  3. 4
      build/test/dependencies/test_fmax.d
  4. 4
      build/test/dependencies/test_fmax_runner.d
  5. 4
      build/test/dependencies/test_log10.d
  6. 4
      build/test/dependencies/test_log10_runner.d
  7. BIN
      build/test/out/c/calculator.o
  8. BIN
      build/test/out/c/test_fmax.o
  9. BIN
      build/test/out/c/test_fmax_runner.o
  10. BIN
      build/test/out/c/test_log10.o
  11. BIN
      build/test/out/c/test_log10_runner.o
  12. BIN
      build/test/out/test_cbrt.out
  13. BIN
      build/test/out/test_ceil.out
  14. BIN
      build/test/out/test_divide.out
  15. BIN
      build/test/out/test_exp.out
  16. BIN
      build/test/out/test_factorial.out
  17. BIN
      build/test/out/test_floor.out
  18. BIN
      build/test/out/test_fmax.out
  19. BIN
      build/test/out/test_log.out
  20. BIN
      build/test/out/test_log10.out
  21. BIN
      build/test/out/test_mod.out
  22. BIN
      build/test/out/test_pow.out
  23. BIN
      build/test/out/test_round.out
  24. BIN
      build/test/out/test_sin.out
  25. BIN
      build/test/out/test_sqrt.out
  26. BIN
      build/test/out/test_subtract.out
  27. 35
      build/test/preprocess/files/test_fmax.c
  28. 49
      build/test/preprocess/files/test_log10.c
  29. 3
      build/test/preprocess/includes/test_fmax.c
  30. 3
      build/test/preprocess/includes/test_log10.c
  31. 2
      build/test/results/test_add.pass
  32. 2
      build/test/results/test_cbrt.pass
  33. 2
      build/test/results/test_ceil.pass
  34. 2
      build/test/results/test_divide.pass
  35. 2
      build/test/results/test_exp.pass
  36. 2
      build/test/results/test_factorial.pass
  37. 2
      build/test/results/test_floor.pass
  38. 18
      build/test/results/test_fmax.pass
  39. 2
      build/test/results/test_log.pass
  40. 18
      build/test/results/test_log10.pass
  41. 2
      build/test/results/test_mod.pass
  42. 2
      build/test/results/test_multiply.pass
  43. 2
      build/test/results/test_pow.pass
  44. 2
      build/test/results/test_round.pass
  45. 2
      build/test/results/test_sin.pass
  46. 2
      build/test/results/test_sqrt.pass
  47. 2
      build/test/results/test_subtract.pass
  48. 87
      build/test/runners/test_fmax_runner.c
  49. 81
      build/test/runners/test_log10_runner.c
  50. 36
      src/main/c/Calculator/calculator.c
  51. 2
      src/main/c/Calculator/calculator.h
  52. 28
      test/Calculator/test_fmax.c
  53. 26
      test/Calculator/test_log10.c

35
build/test/cache/test_fmax.c

@ -0,0 +1,35 @@
#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 test_fmax(void){
double result;
double num1;
double num2;
double max = fmax(14.4,3.4);
result = max;
UnityAssertEqualNumber((UNITY_INT)((14.4)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(25), UNITY_DISPLAY_STYLE_INT);
}

49
build/test/cache/test_log10.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_log10(void){
double result;
double a = 20;
result = log10(a);
return result;
UnityAssertEqualNumber((UNITY_INT)((20)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT);
}

4
build/test/dependencies/test_fmax.d

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

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

4
build/test/dependencies/test_log10.d

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

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

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

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

BIN
build/test/out/c/test_log10_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_fmax.out

BIN
build/test/out/test_log.out

BIN
build/test/out/test_log10.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

35
build/test/preprocess/files/test_fmax.c

@ -0,0 +1,35 @@
#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 test_fmax(void){
double result;
double num1;
double num2;
double max = fmax(14.4,3.4);
result = max;
UnityAssertEqualNumber((UNITY_INT)((14.4)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(25), UNITY_DISPLAY_STYLE_INT);
}

49
build/test/preprocess/files/test_log10.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_log10(void){
double result;
double a = 20;
result = log10(a);
return result;
UnityAssertEqualNumber((UNITY_INT)((20)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT);
}

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

3
build/test/preprocess/includes/test_log10.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.0006854459934402257
:time: 0.0031575530010741204

2
build/test/results/test_cbrt.pass

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

2
build/test/results/test_ceil.pass

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

2
build/test/results/test_divide.pass

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

2
build/test/results/test_exp.pass

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

2
build/test/results/test_factorial.pass

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

2
build/test/results/test_floor.pass

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

18
build/test/results/test_fmax.pass

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

2
build/test/results/test_log.pass

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

18
build/test/results/test_log10.pass

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

2
build/test/results/test_mod.pass

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

2
build/test/results/test_multiply.pass

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

2
build/test/results/test_pow.pass

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

2
build/test/results/test_round.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.003075557993724942
:time: 0.006286452000495046

2
build/test/results/test_sin.pass

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

2
build/test/results/test_sqrt.pass

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

2
build/test/results/test_subtract.pass

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

87
build/test/runners/test_fmax_runner.c

@ -0,0 +1,87 @@
/* 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_fmax(void);
/*=======Mock Management=====*/
static void CMock_Init(void)
{
GlobalExpectCount = 0;
GlobalVerifyOrder = 0;
GlobalOrderError = NULL;
}
static void CMock_Verify(void)
{
}
static void CMock_Destroy(void)
{
}
/*=======Setup (stub)=====*/
void setUp(void) {}
/*=======Teardown (stub)=====*/
void tearDown(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_fmax.c");
run_test(test_fmax, "test_fmax", 14);
return UnityEnd();
}

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

36
src/main/c/Calculator/calculator.c

@ -24,6 +24,9 @@ double exp(double num1);
double ceil(double num1); double ceil(double num1);
double floor(double num1); double floor(double num1);
double round(double num1); double round(double num1);
double fmax(double num1,double num2);
double log10(double num1);
//double exp2(double num1);
int calculator() { int calculator() {
int choice; int choice;
@ -87,8 +90,11 @@ double round(double num1);
printf("21. Exponent\n"); printf("21. Exponent\n");
printf("22. Floor\n"); printf("22. Floor\n");
printf("23. Round\n"); printf("23. Round\n");
//
printf("21. Exit\n");
printf("24. fmaximum");
printf("25. base 10 logarithm");
// printf("26. 2 raise to the power");
// printf("27 trunc");
printf("28. Exit\n");
} }
double performOperation(int choice, double num1, double num2) { double performOperation(int choice, double num1, double num2) {
switch (choice) { switch (choice) {
@ -139,6 +145,14 @@ double round(double num1);
return 0; floor(num1); return 0; floor(num1);
case 23: case 23:
return 0; round(num1); return 0; round(num1);
case 24:
return 0; fmax(num1,num2);
case 25:
return 0; log10(num1);
// case 26:
// return 0; exp2(num1);
// case 27:
// return 0; trunc(num1);
default: default:
return 0.0; return 0.0;
} }
@ -231,3 +245,21 @@ double round(double num1){
double result = num1; double result = num1;
return result; return result;
} }
double fmax(double num1 , double num2){
double maximum = fmax(num1,num2) ;
return maximum;
}
double log10(double num1){
double result = num1;
return result;
}/*
double log10(double num1){
double result = num1;
return result;
}
double trunc(double num1){
double result = num1;
return result;
}
*/

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

@ -16,4 +16,6 @@ double exp(double num1);
double ceil(double num1); double ceil(double num1);
double floor(double num1); double floor(double num1);
double round(double num1); double round(double num1);
double fmax(double num1, double num2);
double log10(double num1);
#endif #endif

28
test/Calculator/test_fmax.c

@ -0,0 +1,28 @@
#ifdef TEST
#include "unity.h"
#include "calculator.h"
/*
( void setUp(void){
//Wenn Funktion Vorraussetzungen braucht
}
void tearDown(void){
}
*/
void test_fmax(void){
/* arrange */
double result;
double num1;
double num2;
double max = fmax(14.4,3.4);
/* act */
result = max;
/* assert */
TEST_ASSERT_EQUAL_INT(14.4, result);// fmax(14.4,3.4);
}
#endif // TEST

26
test/Calculator/test_log10.c

@ -0,0 +1,26 @@
#ifdef TEST
#include "unity.h"
#include "calculator.h"
void setUp(void){
//Wenn Funktion Vorraussetzungen braucht
}
void tearDown(void){
}
void test_log10(void){
/* arrange */
double result;
double a = 20;
result = log10(a);
/* act */
return result;
/* assert */
TEST_ASSERT_EQUAL_INT(20, result);//log10 (20) = 20;
}
#endif // TEST
Loading…
Cancel
Save