Browse Source

Test exp

remotes/origin/Ulrich
Ulriche Nguefack 11 months ago
parent
commit
12fa77b8e3
  1. 49
      build/test/cache/test_ceil.c
  2. 35
      build/test/cache/test_exp.c
  3. 53
      build/test/cache/test_sin.c
  4. 4
      build/test/dependencies/test_ceil.d
  5. 4
      build/test/dependencies/test_ceil_runner.d
  6. 4
      build/test/dependencies/test_exp.d
  7. 3
      build/test/dependencies/test_exp_runner.d
  8. 4
      build/test/dependencies/test_sin.d
  9. 3
      build/test/dependencies/test_sin_runner.d
  10. BIN
      build/test/out/c/calculator.o
  11. BIN
      build/test/out/c/test_ceil.o
  12. BIN
      build/test/out/c/test_ceil_runner.o
  13. BIN
      build/test/out/c/test_exp.o
  14. BIN
      build/test/out/c/test_exp_runner.o
  15. BIN
      build/test/out/c/test_sin.o
  16. BIN
      build/test/out/c/test_sin_runner.o
  17. BIN
      build/test/out/test_cbrt.out
  18. BIN
      build/test/out/test_ceil.out
  19. BIN
      build/test/out/test_divide.out
  20. BIN
      build/test/out/test_exp.out
  21. BIN
      build/test/out/test_factorial.out
  22. BIN
      build/test/out/test_log.out
  23. BIN
      build/test/out/test_mod.out
  24. BIN
      build/test/out/test_pow.out
  25. BIN
      build/test/out/test_sin.out
  26. BIN
      build/test/out/test_sqrt.out
  27. BIN
      build/test/out/test_subtract.out
  28. 49
      build/test/preprocess/files/test_ceil.c
  29. 35
      build/test/preprocess/files/test_exp.c
  30. 53
      build/test/preprocess/files/test_sin.c
  31. 3
      build/test/preprocess/includes/test_ceil.c
  32. 3
      build/test/preprocess/includes/test_exp.c
  33. 3
      build/test/preprocess/includes/test_sin.c
  34. 2
      build/test/results/test_add.pass
  35. 2
      build/test/results/test_cbrt.pass
  36. 18
      build/test/results/test_ceil.pass
  37. 2
      build/test/results/test_divide.pass
  38. 18
      build/test/results/test_exp.pass
  39. 2
      build/test/results/test_factorial.pass
  40. 2
      build/test/results/test_log.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. 18
      build/test/results/test_sin.pass
  45. 2
      build/test/results/test_sqrt.pass
  46. 2
      build/test/results/test_subtract.pass
  47. 81
      build/test/runners/test_ceil_runner.c
  48. 87
      build/test/runners/test_exp_runner.c
  49. 81
      build/test/runners/test_sin_runner.c
  50. 24
      src/main/c/Calculator/calculator.c
  51. 2
      src/main/c/Calculator/calculator.h
  52. 25
      test/Calculator/test_ceil.c
  53. 19
      test/Calculator/test_exp.c
  54. 26
      test/Calculator/test_sin.c

49
build/test/cache/test_ceil.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_ceil(void){
int result;
double a =2.34;
result = ceil(a);
UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT);
}

35
build/test/cache/test_exp.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_exp(void) {
double result;
double a =1;
double exponent = exp(a);
result = exponent;
UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(16), UNITY_DISPLAY_STYLE_INT);
}

53
build/test/cache/test_sin.c

@ -0,0 +1,53 @@
#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_sin(void){
double num1=20;
double result;
double sine = num1 *
3.14159265358979323846
/180.0;
result = sine;
UnityAssertEqualNumber((UNITY_INT)((0.34)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT);
}

4
build/test/dependencies/test_ceil.d

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

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

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

@ -0,0 +1,3 @@
build/test/out/c/test_exp_runner.o: build/test/runners/test_exp_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_sin.d

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

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

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

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

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

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

BIN
build/test/out/c/test_sin_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_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

49
build/test/preprocess/files/test_ceil.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_ceil(void){
int result;
double a =2.34;
result = ceil(a);
UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT);
}

35
build/test/preprocess/files/test_exp.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_exp(void) {
double result;
double a =1;
double exponent = exp(a);
result = exponent;
UnityAssertEqualNumber((UNITY_INT)((1)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(16), UNITY_DISPLAY_STYLE_INT);
}

53
build/test/preprocess/files/test_sin.c

@ -0,0 +1,53 @@
#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_sin(void){
double num1=20;
double result;
double sine = num1 *
3.14159265358979323846
/180.0;
result = sine;
UnityAssertEqualNumber((UNITY_INT)((0.34)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT);
}

3
build/test/preprocess/includes/test_ceil.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_exp.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_sin.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.001341750001301989
:time: 0.004256184998666868

2
build/test/results/test_cbrt.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.003224601998226717
:time: 0.004384817002573982

18
build/test/results/test_ceil.pass

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

2
build/test/results/test_divide.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0032165549928322434
:time: 0.004329051997046918

18
build/test/results/test_exp.pass

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

2
build/test/results/test_factorial.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0032816580205690116
:time: 0.0043980109912808985

2
build/test/results/test_log.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.003215620992705226
:time: 0.0046040110173635185

2
build/test/results/test_mod.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.003226413013180718
:time: 0.004433333990164101

2
build/test/results/test_multiply.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.00324131001252681
:time: 0.004367012996226549

2
build/test/results/test_pow.pass

@ -19,4 +19,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0032054850016720593
:time: 0.004291344986995682

18
build/test/results/test_sin.pass

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

2
build/test/results/test_sqrt.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.0031778719858266413
:time: 0.004461465985514224

2
build/test/results/test_subtract.pass

@ -15,4 +15,4 @@
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.006584955001017079
:time: 0.004360714985523373

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

87
build/test/runners/test_exp_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_exp(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_exp.c");
run_test(test_exp, "test_exp", 8);
return UnityEnd();
}

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

24
src/main/c/Calculator/calculator.c

@ -13,13 +13,16 @@ double permutation(int n, int r);
double combination(int n, int r); double combination(int n, int r);
double pow(double num1, double num2); double pow(double num1, double num2);
int mod(int num1,int num2); int mod(int num1,int num2);
double log(num1);
double log(double num1);
double sqrt(double num1); double sqrt(double num1);
double cbrt(num1);
double cbrt(double num1);
int multiply (int num1,int num2); int multiply (int num1,int num2);
double divide (double num1, double num2); double divide (double num1, double num2);
int add (int num1, int num2); int add (int num1, int num2);
int subtract(int num1, int num2); int subtract(int num1, int num2);
double exp(double num1);
double ceil(double num1);
int calculator() { int calculator() {
int choice; int choice;
@ -79,7 +82,10 @@ int subtract(int num1, int num2);
printf("17. Tangent\n"); printf("17. Tangent\n");
printf("18. Permutation\n"); printf("18. Permutation\n");
printf("19. Combination\n"); printf("19. Combination\n");
printf("20. Exit\n");
printf("20. Ceil\n");
printf("21. Exponent\n");
//
printf("21. Exit\n");
} }
double performOperation(int choice, double num1, double num2) { double performOperation(int choice, double num1, double num2) {
switch (choice) { switch (choice) {
@ -122,6 +128,10 @@ int subtract(int num1, int num2);
return permutation((int)num1, (int)num2); return permutation((int)num1, (int)num2);
case 19: case 19:
return combination((int)num1, (int)num2); return combination((int)num1, (int)num2);
case 20:
return 0; ceil(num1);
case 21:
return 0; exp(num1);
default: default:
return 0.0; return 0.0;
} }
@ -197,3 +207,11 @@ int subtract(int num1, int num2){
int subtraction = num1 - num2; int subtraction = num1 - num2;
return subtraction; return subtraction;
} }
double exp(double num1){
double result = num1;
return result;
}
double ceil(double num1){
double result = num1;
return result;
}

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

@ -12,4 +12,6 @@ int multiply(int num1,int num2);
double divide(double num1,double num2); double divide(double num1,double num2);
int add(int num1 ,int num2); int add(int num1 ,int num2);
int subtract(int num1, int num2); int subtract(int num1, int num2);
double exp(double num1);
double ceil(double num1);
#endif #endif

25
test/Calculator/test_ceil.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_ceil(void){
/* arrange */
int result;
double a =2.34;
/* act */
result = ceil(a);
/* assert */
TEST_ASSERT_EQUAL_INT(2, result);//5 / 5 + 5 = 6
}
#endif // TEST

19
test/Calculator/test_exp.c

@ -0,0 +1,19 @@
#ifdef TEST
#include "unity.h"
#include "calculator.h"
void test_exp(void) {
/* arrange */
double result;
double a =1;
double exponent = exp(a);
/* act */
result = exponent;
/* assert */
TEST_ASSERT_EQUAL_INT(1, result);//5 / 5 + 5 = 6
}
#endif // TEST

26
test/Calculator/test_sin.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_sin(void){
/* arrange */
double num1=20;
double result;
double sine = num1 * M_PI /180.0;
/* act */
result = sine;
/* assert */
TEST_ASSERT_EQUAL_INT(0.34, result);//5 / 5 + 5 = 6
}
#endif // TEST
Loading…
Cancel
Save