Browse Source

Test pow negative Zahlen

remotes/origin/Ulrich
Ulriche Nguefack 11 months ago
parent
commit
3b586bfd93
  1. 36
      build/test/cache/test_add.c
  2. BIN
      build/test/out/c/test_add.o
  3. BIN
      build/test/out/c/test_add_runner.o
  4. BIN
      build/test/out/test_add.out
  5. 36
      build/test/preprocess/files/test_add.c
  6. 12
      build/test/results/test_add.pass
  7. 2
      build/test/results/test_template.pass
  8. 6
      build/test/runners/test_add_runner.c
  9. 20
      test/Calculator/test_add.c

36
build/test/cache/test_add.c

@ -20,7 +20,7 @@ void tearDown(void){
void test_adding_whole_numbers(void){
void test_pow_N_N(void){
@ -28,7 +28,7 @@ void test_adding_whole_numbers(void){
double b = 3; double b = 3;
double a = 3.5;
double a = 3;
@ -40,10 +40,40 @@ void test_adding_whole_numbers(void){
UnityAssertEqualNumber((UNITY_INT)((42.875)), (UNITY_INT)((result)), (
UnityAssertEqualNumber((UNITY_INT)((27)), (UNITY_INT)((result)), (
((void *)0) ((void *)0)
), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT); ), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT);
} }
void test_pow_Z_N(void){
double result;
double b = 3;
double a = -3;
result = pow(a, b);
UnityAssertEqualNumber((UNITY_INT)((-27)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(36), UNITY_DISPLAY_STYLE_INT);
}

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

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

BIN
build/test/out/test_add.out

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

@ -20,7 +20,7 @@ void tearDown(void){
void test_adding_whole_numbers(void){
void test_pow_N_N(void){
@ -28,7 +28,7 @@ void test_adding_whole_numbers(void){
double b = 3; double b = 3;
double a = 3.5;
double a = 3;
@ -40,10 +40,40 @@ void test_adding_whole_numbers(void){
UnityAssertEqualNumber((UNITY_INT)((42.875)), (UNITY_INT)((result)), (
UnityAssertEqualNumber((UNITY_INT)((27)), (UNITY_INT)((result)), (
((void *)0) ((void *)0)
), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT); ), (UNITY_UINT)(23), UNITY_DISPLAY_STYLE_INT);
} }
void test_pow_Z_N(void){
double result;
double b = 3;
double a = -3;
result = pow(a, b);
UnityAssertEqualNumber((UNITY_INT)((-27)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(36), UNITY_DISPLAY_STYLE_INT);
}

12
build/test/results/test_add.pass

@ -3,16 +3,20 @@
:path: test/Calculator :path: test/Calculator
:file: test_add.c :file: test_add.c
:successes: :successes:
- :test: test_adding_whole_numbers
- :test: test_pow_N_N
:line: 13 :line: 13
:message: '' :message: ''
:unity_test_time: 0 :unity_test_time: 0
- :test: test_pow_Z_N
:line: 26
:message: ''
:unity_test_time: 0
:failures: [] :failures: []
:ignores: [] :ignores: []
:counts: :counts:
:total: 1
:passed: 1
:total: 2
:passed: 2
:failed: 0 :failed: 0
:ignored: 0 :ignored: 0
:stdout: [] :stdout: []
:time: 0.006848459015600383
:time: 0.007150935009121895

2
build/test/results/test_template.pass

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

6
build/test/runners/test_add_runner.c

@ -10,7 +10,8 @@ char* GlobalOrderError;
/*=======External Functions This Runner Calls=====*/ /*=======External Functions This Runner Calls=====*/
extern void setUp(void); extern void setUp(void);
extern void tearDown(void); extern void tearDown(void);
extern void test_adding_whole_numbers(void);
extern void test_pow_N_N(void);
extern void test_pow_Z_N(void);
/*=======Mock Management=====*/ /*=======Mock Management=====*/
@ -75,7 +76,8 @@ static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE l
int main(void) int main(void)
{ {
UnityBegin("test_add.c"); UnityBegin("test_add.c");
run_test(test_adding_whole_numbers, "test_adding_whole_numbers", 13);
run_test(test_pow_N_N, "test_pow_N_N", 13);
run_test(test_pow_Z_N, "test_pow_Z_N", 26);
return UnityEnd(); return UnityEnd();
} }

20
test/Calculator/test_add.c

@ -10,17 +10,31 @@ void tearDown(void){
} }
void test_adding_whole_numbers(void){
void test_pow_N_N(void){
/* arrange */ /* arrange */
double result; double result;
double b = 3; double b = 3;
double a = 3.5;
double a = 3;
/* act */ /* act */
result = pow(a, b); result = pow(a, b);
/* assert */ /* assert */
TEST_ASSERT_EQUAL_INT(42.875, result);//3 * 3 * 3 = 27
TEST_ASSERT_EQUAL_INT(27, result);//3 * 3 * 3 = 27
} }
void test_pow_Z_N(void){
/* arrange */
double result;
double b = 3;
double a = -3;
/* act */
result = pow(a, b);
/* assert */
TEST_ASSERT_EQUAL_INT(-27, result);//3 * 3 * 3 = 27
}
#endif // TEST #endif // TEST
Loading…
Cancel
Save