Browse Source

Test pow

remotes/origin/Ulrich
Ulriche Nguefack 11 months ago
parent
commit
f2fed0c2ca
  1. 0
      And
  2. 0
      Shell
  3. 0
      build/release/dependencies/force_build
  4. 1
      build/release/dependencies/top.d
  5. BIN
      build/release/out/c/top.o
  6. 2
      build/test/cache/defines_dependency.yml
  7. 12
      build/test/cache/input.yml
  8. 49
      build/test/cache/test_add.c
  9. 2
      build/test/cache/test_template.c
  10. 1
      build/test/dependencies/calculator.d
  11. 0
      build/test/dependencies/force_build
  12. 4
      build/test/dependencies/test_add.d
  13. 3
      build/test/dependencies/test_add_runner.d
  14. 4
      build/test/dependencies/test_template_runner.d
  15. BIN
      build/test/out/c/calculator.o
  16. BIN
      build/test/out/c/test_add.o
  17. BIN
      build/test/out/c/test_add_runner.o
  18. BIN
      build/test/out/c/test_template_runner.o
  19. BIN
      build/test/out/test_add.out
  20. BIN
      build/test/out/test_template.out
  21. 49
      build/test/preprocess/files/test_add.c
  22. 2
      build/test/preprocess/files/test_template.c
  23. 3
      build/test/preprocess/includes/test_add.c
  24. 2
      build/test/preprocess/includes/test_template.c
  25. 18
      build/test/results/test_add.pass
  26. 2
      build/test/results/test_template.pass
  27. 81
      build/test/runners/test_add_runner.c
  28. 24
      src/main/c/Calculator/calculator.c
  29. 8
      src/main/c/Calculator/calculator.h
  30. 26
      test/Calculator/test_add.c

0
And

0
Shell

0
build/release/dependencies/force_build

1
build/release/dependencies/top.d

@ -0,0 +1 @@
build/release/out/c/top.o: src/main/c/Quiz/top.c

BIN
build/release/out/c/top.o

2
build/test/cache/defines_dependency.yml

@ -1,3 +1,5 @@
---
src/main/c/Template/game100.c:
- TEST
src/main/c/Calculator/calculator.c:
- TEST

12
build/test/cache/input.yml

@ -77,10 +77,10 @@
:testfail: ".fail"
:dependencies: ".d"
:unity:
:vendor_path: "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor"
:vendor_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor"
:defines: []
:cmock:
:vendor_path: "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor"
:vendor_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor"
:defines: []
:includes: []
:mock_prefix: mock_
@ -99,7 +99,7 @@
:verbosity: 3
:unity_helper: false
:cexception:
:vendor_path: "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor"
:vendor_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor"
:defines: []
:test_runner:
:includes: []
@ -257,13 +257,13 @@
:arguments: []
:plugins:
:load_paths:
- "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/lib/../plugins"
- "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins"
:enabled:
- stdout_pretty_tests_report
- module_generator
:display_raw_test_results: false
:stdout_pretty_tests_report_path: "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/lib/../plugins/stdout_pretty_tests_report"
:module_generator_path: "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/lib/../plugins/module_generator"
:stdout_pretty_tests_report_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/stdout_pretty_tests_report"
:module_generator_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/module_generator"
:gcov:
:reports:
- HtmlDetailed

49
build/test/cache/test_add.c

@ -0,0 +1,49 @@
#include "build/temp/../../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_adding_whole_numbers(void){
double result;
double b = 3;
double a = 3.5;
result = pow(a, b);
UnityAssertEqualNumber((UNITY_INT)((42.875)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT);
}

2
build/test/cache/test_template.c

@ -1,5 +1,5 @@
#include "src/main/c/Template/game100.h"
#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"
#include "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"

1
build/test/dependencies/calculator.d

@ -0,0 +1 @@
build/test/out/c/calculator.o: src/main/c/Calculator/calculator.c

0
build/test/dependencies/force_build

4
build/test/dependencies/test_add.d

@ -0,0 +1,4 @@
build/test/out/c/test_add.o: test/Calculator/test_add.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 \
test/Calculator/../../src/main/c/Calculator/calculator.h

3
build/test/dependencies/test_add_runner.d

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

@ -1,4 +1,4 @@
build/test/out/c/test_template_runner.o: \
build/test/runners/test_template_runner.c \
/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \
/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h
/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_add.o

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

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

BIN
build/test/out/test_add.out

BIN
build/test/out/test_template.out

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

@ -0,0 +1,49 @@
#include "build/temp/../../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_adding_whole_numbers(void){
double result;
double b = 3;
double a = 3.5;
result = pow(a, b);
UnityAssertEqualNumber((UNITY_INT)((42.875)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT);
}

2
build/test/preprocess/files/test_template.c

@ -1,5 +1,5 @@
#include "src/main/c/Template/game100.h"
#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"
#include "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"

3
build/test/preprocess/includes/test_add.c

@ -0,0 +1,3 @@
---
- "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"
- build/temp/../../src/main/c/Calculator/calculator.h

2
build/test/preprocess/includes/test_template.c

@ -1,3 +1,3 @@
---
- "/var/lib/gems/2.7.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.h"
- src/main/c/Template/game100.h

18
build/test/results/test_add.pass

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

2
build/test/results/test_template.pass

@ -19,4 +19,4 @@
:failed: 0
:ignored: 0
:stdout: []
:time: 0.002492974977940321
:time: 0.00312035801471211

81
build/test/runners/test_add_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_adding_whole_numbers(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_add.c");
run_test(test_adding_whole_numbers, "test_adding_whole_numbers", 13);
return UnityEnd();
}

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

@ -10,9 +10,9 @@ int getIntInput(const char *message);
double factorial(double num);
double permutation(int n, int r);
double combination(int n, int r);
double pow(double num1, int num2);
double pow(double num1, double num2);
int main() {
int calculator() {
int choice;
double num1, num2, result;
@ -85,29 +85,29 @@ double pow(double num1, int num2);
case 5:
return pow(num1, num2);
case 6:
return fmod(num1, num2);
return 0;// fmod(num1, num2);
case 7:
return log(num1);
return 0;// log(num1);
case 8:
return pow(num1, num2);
case 9:
return sqrt(num1);
return 0;// sqrt(num1);
case 10:
return num1 * num1;
case 11:
return num1 * num1 * num1;
case 12:
return cbrt(num1);
return 0;// cbrt(num1);
case 13:
return factorial(num1);
case 14:
return pow(num1, num2);
case 15:
return sin(num1 * M_PI / 180.0);
return 0;// sin(num1 * M_PI / 180.0);
case 16:
return cos(num1 * M_PI / 180.0);
return 0;// cos(num1 * M_PI / 180.0);
case 17:
return tan(num1 * M_PI / 180.0);
return 0;// tan(num1 * M_PI / 180.0);
case 18:
return permutation((int)num1, (int)num2);
@ -149,10 +149,10 @@ int getIntInput(const char *message) {
return input;
}
double pow(double num1, int num2){
double pow(double num1, double num2){
double product = 1;
for(int i = 0; i < num2; ){
for(int i = 0; i < num2; i++){
product *= num1;
}
return product;
}
}

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

@ -0,0 +1,8 @@
#ifndef CALCULATOR_H
#define CALCULATOR_H
int calculator();
double pow(double num1, double num2);
double factorial(double num);
#endif

26
test/Calculator/test_add.c

@ -0,0 +1,26 @@
#ifdef TEST
#include "unity.h"
#include "../../src/main/c/Calculator/calculator.h"
void setUp(void){
//Wenn Funktion Vorraussetzungen braucht
}
void tearDown(void){
}
void test_adding_whole_numbers(void){
/* arrange */
double result;
double b = 3;
double a = 3.5;
/* act */
result = pow(a, b);
/* assert */
TEST_ASSERT_EQUAL_INT(42.875, result);//3 * 3 * 3 = 27
}
#endif // TEST
Loading…
Cancel
Save