diff --git a/build/test/cache/test_sendmoney.c b/build/test/cache/test_sendmoney.c index 8f61783..e5b7922 100644 --- a/build/test/cache/test_sendmoney.c +++ b/build/test/cache/test_sendmoney.c @@ -32,6 +32,8 @@ void test_sendmoney_NeedToImplement(void) int accountNumber2 = 5555557; + int accountNumber3 = 53323; + _Bool @@ -44,6 +46,12 @@ void test_sendmoney_NeedToImplement(void) expected2; + + + _Bool + + expected3; + @@ -52,14 +60,80 @@ void test_sendmoney_NeedToImplement(void) 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); } diff --git a/build/test/out/c/sendmoney.o b/build/test/out/c/sendmoney.o index ad8e7b2..954e668 100644 Binary files a/build/test/out/c/sendmoney.o and b/build/test/out/c/sendmoney.o differ diff --git a/build/test/out/c/test_sendmoney.o b/build/test/out/c/test_sendmoney.o index 73a4a7e..b1265af 100644 Binary files a/build/test/out/c/test_sendmoney.o and b/build/test/out/c/test_sendmoney.o differ diff --git a/build/test/out/c/test_sendmoney_runner.o b/build/test/out/c/test_sendmoney_runner.o index 83b78e3..4f50a88 100644 Binary files a/build/test/out/c/test_sendmoney_runner.o and b/build/test/out/c/test_sendmoney_runner.o differ diff --git a/build/test/out/test_sendmoney.out b/build/test/out/test_sendmoney.out index 939439e..9a1ae36 100644 Binary files a/build/test/out/test_sendmoney.out and b/build/test/out/test_sendmoney.out differ diff --git a/build/test/preprocess/files/test_sendmoney.c b/build/test/preprocess/files/test_sendmoney.c index 8f61783..e5b7922 100644 --- a/build/test/preprocess/files/test_sendmoney.c +++ b/build/test/preprocess/files/test_sendmoney.c @@ -32,6 +32,8 @@ void test_sendmoney_NeedToImplement(void) int accountNumber2 = 5555557; + int accountNumber3 = 53323; + _Bool @@ -44,6 +46,12 @@ void test_sendmoney_NeedToImplement(void) expected2; + + + _Bool + + expected3; + @@ -52,14 +60,80 @@ void test_sendmoney_NeedToImplement(void) 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); } diff --git a/build/test/results/test_sendmoney.fail b/build/test/results/test_sendmoney.fail new file mode 100644 index 0000000..564d36f --- /dev/null +++ b/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 diff --git a/build/test/results/test_sendmoney.pass b/build/test/results/test_sendmoney.pass deleted file mode 100644 index adf49b2..0000000 --- a/build/test/results/test_sendmoney.pass +++ /dev/null @@ -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 diff --git a/build/test/runners/test_sendmoney_runner.c b/build/test/runners/test_sendmoney_runner.c index 63fa0b9..8f4a533 100644 --- a/build/test/runners/test_sendmoney_runner.c +++ b/build/test/runners/test_sendmoney_runner.c @@ -11,6 +11,8 @@ char* GlobalOrderError; extern void setUp(void); extern void tearDown(void); extern void test_sendmoney_NeedToImplement(void); +extern void test_getAvailableAccountBalance(void); +extern void test_getAmount(void); /*=======Mock Management=====*/ @@ -76,6 +78,8 @@ int main(void) { UnityBegin("test_sendmoney.c"); 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(); } diff --git a/src/CustomerData.txt b/src/CustomerData.txt index b01179a..e2ea529 100644 --- a/src/CustomerData.txt +++ b/src/CustomerData.txt @@ -3,4 +3,4 @@ ID=1234 forename=Max Surname=Mustermann password=example -balance=23 +balance=1007 diff --git a/src/a.exe b/src/a.exe index 0763b24..c9adfa1 100644 Binary files a/src/a.exe and b/src/a.exe differ diff --git a/src/sendmoney.c b/src/sendmoney.c index 127700e..62e66c0 100644 --- a/src/sendmoney.c +++ b/src/sendmoney.c @@ -1,14 +1,11 @@ #include "sendmoney.h" -int main() -{ - SendMoney(); -} + double getAvailableAccountBalance(int length) { double availableBalance; FILE *fp; - fp = fopen("CustomerData.txt", "r"); + fp = fopen("src/CustomerData.txt", "r"); if (fp == 0) { @@ -22,15 +19,15 @@ double getAvailableAccountBalance(int length) while (fgets(line, sizeof line, fp) != NULL) { - if (sscanf(line, "balance=%lf", &availableBalance) == 1) + if (sscanf(line, "balance =%lf", &availableBalance) == 1) { break; } } - fclose(fp); + printf("your balance is : %lf\n", availableBalance); + fclose(fp); } - return availableBalance; } diff --git a/test/test_sendmoney.c b/test/test_sendmoney.c index 9db034c..28e0d3b 100644 --- a/test/test_sendmoney.c +++ b/test/test_sendmoney.c @@ -16,17 +16,21 @@ void test_sendmoney_NeedToImplement(void) int accountNumber = 1234567; int accountNumber2 = 5555557; + int accountNumber3 = 5332323; bool expected; bool expected2; + bool expected3; // Act expected = checkAccount(accountNumber); expected2 = checkAccount(accountNumber2); + expected3 = checkAccount(accountNumber3); // Assert TEST_ASSERT_TRUE(expected); TEST_ASSERT_TRUE(expected2); + TEST_ASSERT_TRUE(expected3); } // hier wird die Methode getAvailableAccountBalance()getestet @@ -35,14 +39,15 @@ void test_getAvailableAccountBalance(void) // Arrage - double expected = 500.0; + double expected1 = 24.0; + int leng = 2; // Act - double result = getAvailableAccountBalance(expected1); + double result = getAvailableAccountBalance(leng); // Assert - TEST_ASSERT_EQUAL(expected, result); + TEST_ASSERT_EQUAL(expected1, result); } // hier wird die Methode getAmount() getestet void test_getAmount(void)