Browse Source

test sendmoneyNeedToImplement

remotes/origin/feature/send-money
fdai6618 2 years ago
parent
commit
466eb53425
  1. 78
      build/test/cache/test_sendmoney.c
  2. BIN
      build/test/out/c/sendmoney.o
  3. BIN
      build/test/out/c/test_sendmoney.o
  4. BIN
      build/test/out/c/test_sendmoney_runner.o
  5. BIN
      build/test/out/test_sendmoney.out
  6. 78
      build/test/preprocess/files/test_sendmoney.c
  7. 27
      build/test/results/test_sendmoney.fail
  8. 18
      build/test/results/test_sendmoney.pass
  9. 4
      build/test/runners/test_sendmoney_runner.c
  10. 2
      src/CustomerData.txt
  11. BIN
      src/a.exe
  12. 11
      src/sendmoney.c
  13. 11
      test/test_sendmoney.c

78
build/test/cache/test_sendmoney.c

@ -32,6 +32,8 @@ void test_sendmoney_NeedToImplement(void)
int accountNumber2 = 5555557; int accountNumber2 = 5555557;
int accountNumber3 = 53323;
_Bool _Bool
@ -46,20 +48,92 @@ void test_sendmoney_NeedToImplement(void)
_Bool
expected3;
expected = checkAccount(accountNumber); expected = checkAccount(accountNumber);
expected2 = checkAccount(accountNumber2); expected2 = checkAccount(accountNumber2);
expected3 = checkAccount(accountNumber3);
do {if ((expected)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(31)));}} while(0);
do {if ((expected2)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(32)));}} while(0);
do {if ((expected3)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(33)));}} while(0);
}
void test_getAvailableAccountBalance(void)
{
double expected1 = 24.0;
int leng = 2;
double result = getAvailableAccountBalance(leng);
UnityAssertEqualNumber((UNITY_INT)((expected1)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(50), UNITY_DISPLAY_STYLE_INT);
}
void test_getAmount(void)
{
float expected = 500.1;
float result = getAmount(expected);
UnityAssertEqualNumber((UNITY_INT)((expected)), (UNITY_INT)((result)), (
do {if ((expected)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(28)));}} while(0);
((void *)0)
do {if ((expected2)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(29)));}} while(0);
), (UNITY_UINT)(60), UNITY_DISPLAY_STYLE_INT);
} }

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

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

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

BIN
build/test/out/test_sendmoney.out

78
build/test/preprocess/files/test_sendmoney.c

@ -32,6 +32,8 @@ void test_sendmoney_NeedToImplement(void)
int accountNumber2 = 5555557; int accountNumber2 = 5555557;
int accountNumber3 = 53323;
_Bool _Bool
@ -46,20 +48,92 @@ void test_sendmoney_NeedToImplement(void)
_Bool
expected3;
expected = checkAccount(accountNumber); expected = checkAccount(accountNumber);
expected2 = checkAccount(accountNumber2); expected2 = checkAccount(accountNumber2);
expected3 = checkAccount(accountNumber3);
do {if ((expected)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(31)));}} while(0);
do {if ((expected2)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(32)));}} while(0);
do {if ((expected3)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(33)));}} while(0);
}
void test_getAvailableAccountBalance(void)
{
double expected1 = 24.0;
int leng = 2;
double result = getAvailableAccountBalance(leng);
UnityAssertEqualNumber((UNITY_INT)((expected1)), (UNITY_INT)((result)), (
((void *)0)
), (UNITY_UINT)(50), UNITY_DISPLAY_STYLE_INT);
}
void test_getAmount(void)
{
float expected = 500.1;
float result = getAmount(expected);
UnityAssertEqualNumber((UNITY_INT)((expected)), (UNITY_INT)((result)), (
do {if ((expected)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(28)));}} while(0);
((void *)0)
do {if ((expected2)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(29)));}} while(0);
), (UNITY_UINT)(60), UNITY_DISPLAY_STYLE_INT);
} }

27
build/test/results/test_sendmoney.fail

@ -0,0 +1,27 @@
---
:source:
:path: test
:file: test_sendmoney.c
:successes:
- :test: test_getAmount
:line: 53
:message: ''
:unity_test_time: 0
:failures:
- :test: test_sendmoney_NeedToImplement
:line: 33
:message: Expected TRUE Was FALSE
:unity_test_time: 0
- :test: test_getAvailableAccountBalance
:line: 50
:message: Expected 24 Was 0
:unity_test_time: 0
:ignores: []
:counts:
:total: 3
:passed: 1
:failed: 2
:ignored: 0
:stdout:
- 'your balance is : 0.000000'
:time: 0.06836329999896407

18
build/test/results/test_sendmoney.pass

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

4
build/test/runners/test_sendmoney_runner.c

@ -11,6 +11,8 @@ char* GlobalOrderError;
extern void setUp(void); extern void setUp(void);
extern void tearDown(void); extern void tearDown(void);
extern void test_sendmoney_NeedToImplement(void); extern void test_sendmoney_NeedToImplement(void);
extern void test_getAvailableAccountBalance(void);
extern void test_getAmount(void);
/*=======Mock Management=====*/ /*=======Mock Management=====*/
@ -76,6 +78,8 @@ int main(void)
{ {
UnityBegin("test_sendmoney.c"); UnityBegin("test_sendmoney.c");
run_test(test_sendmoney_NeedToImplement, "test_sendmoney_NeedToImplement", 13); run_test(test_sendmoney_NeedToImplement, "test_sendmoney_NeedToImplement", 13);
run_test(test_getAvailableAccountBalance, "test_getAvailableAccountBalance", 37);
run_test(test_getAmount, "test_getAmount", 53);
return UnityEnd(); return UnityEnd();
} }

2
src/CustomerData.txt

@ -3,4 +3,4 @@ ID=1234
forename=Max forename=Max
Surname=Mustermann Surname=Mustermann
password=example password=example
balance=23
balance=1007

BIN
src/a.exe

11
src/sendmoney.c

@ -1,14 +1,11 @@
#include "sendmoney.h" #include "sendmoney.h"
int main()
{
SendMoney();
}
double getAvailableAccountBalance(int length) double getAvailableAccountBalance(int length)
{ {
double availableBalance; double availableBalance;
FILE *fp; FILE *fp;
fp = fopen("CustomerData.txt", "r");
fp = fopen("src/CustomerData.txt", "r");
if (fp == 0) if (fp == 0)
{ {
@ -27,10 +24,10 @@ double getAvailableAccountBalance(int length)
break; break;
} }
} }
fclose(fp);
printf("your balance is : %lf\n", availableBalance); printf("your balance is : %lf\n", availableBalance);
fclose(fp);
} }
return availableBalance; return availableBalance;
} }

11
test/test_sendmoney.c

@ -16,17 +16,21 @@ void test_sendmoney_NeedToImplement(void)
int accountNumber = 1234567; int accountNumber = 1234567;
int accountNumber2 = 5555557; int accountNumber2 = 5555557;
int accountNumber3 = 5332323;
bool expected; bool expected;
bool expected2; bool expected2;
bool expected3;
// Act // Act
expected = checkAccount(accountNumber); expected = checkAccount(accountNumber);
expected2 = checkAccount(accountNumber2); expected2 = checkAccount(accountNumber2);
expected3 = checkAccount(accountNumber3);
// Assert // Assert
TEST_ASSERT_TRUE(expected); TEST_ASSERT_TRUE(expected);
TEST_ASSERT_TRUE(expected2); TEST_ASSERT_TRUE(expected2);
TEST_ASSERT_TRUE(expected3);
} }
// hier wird die Methode getAvailableAccountBalance()getestet // hier wird die Methode getAvailableAccountBalance()getestet
@ -35,14 +39,15 @@ void test_getAvailableAccountBalance(void)
// Arrage // Arrage
double expected = 500.0;
double expected1 = 24.0;
int leng = 2;
// Act // Act
double result = getAvailableAccountBalance(expected1);
double result = getAvailableAccountBalance(leng);
// Assert // Assert
TEST_ASSERT_EQUAL(expected, result);
TEST_ASSERT_EQUAL(expected1, result);
} }
// hier wird die Methode getAmount() getestet // hier wird die Methode getAmount() getestet
void test_getAmount(void) void test_getAmount(void)

Loading…
Cancel
Save