diff --git a/build/test/cache/defines_dependency.yml b/build/test/cache/defines_dependency.yml index 64f9ba3..217b8d2 100644 --- a/build/test/cache/defines_dependency.yml +++ b/build/test/cache/defines_dependency.yml @@ -1,3 +1,3 @@ --- -src/mainMenu.c: +src/updateCustomerAccountBalance.c: - TEST diff --git a/build/test/cache/input.yml b/build/test/cache/input.yml index e0eb2fd..bc8023f 100644 --- a/build/test/cache/input.yml +++ b/build/test/cache/input.yml @@ -77,10 +77,10 @@ :testfail: ".fail" :dependencies: ".d" :unity: - :vendor_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor" + :vendor_path: "/Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/vendor" :defines: [] :cmock: - :vendor_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor" + :vendor_path: "/Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.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/3.0.0/gems/ceedling-0.31.1/vendor" + :vendor_path: "/Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/vendor" :defines: [] :test_runner: :includes: [] @@ -223,13 +223,13 @@ :arguments: [] :plugins: :load_paths: - - "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins" + - "/Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.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/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" + :stdout_pretty_tests_report_path: "/Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/lib/../plugins/stdout_pretty_tests_report" + :module_generator_path: "/Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/lib/../plugins/module_generator" :gcov: :reports: - HtmlDetailed diff --git a/build/test/cache/test_mainMenu.c b/build/test/cache/test_mainMenu.c deleted file mode 100644 index c8bdf9f..0000000 --- a/build/test/cache/test_mainMenu.c +++ /dev/null @@ -1,299 +0,0 @@ -#include "src/mainMenu.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_agePermissionValidAge(void) - -{ - - - - - - - - - - int validAge[83]; - - - - - - _Bool - - validAgeResult[83]; - - - - int j=0; - - - - for(int i =18;i<101;i++){ - - - - validAge[j]= i; - - j++; - - } - - - - - - - - for(int i=0;i<83;i++){ - - - - validAgeResult[i] = agePermission(validAge[i]); - - } - - - - - - - - for(int i=0;i<83;i++){ - - - - do {if ((validAgeResult[i])) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(44)));}} while(0); - - - - } - - - -} - - - -void test_agePermissionInvalidAge(void) - -{ - - - - - - - - - - - - int invalidAge[117]; - - - - - - _Bool - - invalidAgeResult[117]; - - - - int j=0; - - - - for(int i =-100;i<18;i++){ - - - - invalidAge[j]= i; - - j++; - - } - - - - - - - - for(int i=0;i<117;i++){ - - - - invalidAgeResult[i] = agePermission(invalidAge[i]); - - - - } - - - - - - - - for(int i=0;i<117;i++){ - - - - do {if (!(invalidAgeResult[i])) {} else {UnityFail( ((" Expected FALSE Was TRUE")), (UNITY_UINT)((UNITY_UINT)(81)));}} while(0); - - - - } - - - -} - - - -void test_IsInteger(void) - -{ - - - - - - - - char* inputIsInteger[] = {"-10000000","-2000000","-354698","-66667","-7878","-987","-64","-5","0","1","2","10","201","333","4321","56974","698751","7878989","88954621" }; - - - - - - _Bool - - inputIsIntegerResult[19]; - - - - - - - - for(int i=0;i<19;i++) - - { - - - - inputIsIntegerResult[i] = checkIfInteger(inputIsInteger[i]); - - - - } - - - - - - - - for(int i=0;i<19;i++) - - { - - - - do {if ((inputIsIntegerResult[i])) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(110)));}} while(0); - - - - } - - - -} - - - -void test_IsNotInteger(void) - -{ - - - - - - - - char* inputIsNotInteger[] = {"0.15","3.141592653589793238","5.3254f","-6.264","-7878.3261","foo","Bar","FIZZ","buzZ","joHN","jAnE","foo-bar","3,15","2k13",""," ","-","+","/*-+.,/=" }; - - - - - - _Bool - - inputIsNotIntegerResult[19]; - - - - - - - - for(int i=0;i<19;i++) - - { - - - - inputIsNotIntegerResult[i] = checkIfInteger(inputIsNotInteger[i]); - - - - } - - - - - - - - for(int i=0;i<19;i++) - - { - - - - do {if (!(inputIsNotIntegerResult[i])) {} else {UnityFail( ((" Expected FALSE Was TRUE")), (UNITY_UINT)((UNITY_UINT)(139)));}} while(0); - - - - } - - - -} diff --git a/build/test/cache/test_updateCustomerAccountBalance.c b/build/test/cache/test_updateCustomerAccountBalance.c new file mode 100644 index 0000000..5b6d44a --- /dev/null +++ b/build/test/cache/test_updateCustomerAccountBalance.c @@ -0,0 +1,63 @@ +#include "src/updateCustomerAccountBalance.h" +#include "/Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + + + +void setUp(void) + +{ + +} + + + +void tearDown(void) + +{ + +} + + + +void test_updateAvailableAccountBalanceSuccess(void){ + + + + int id1 = 1234; + + int id2 = 1327; + + int id3 = 1666; + + + + int newBalance1=500; + + int newBalance2=800; + + int newBalance3=700; + + + + _Bool results1=updateAvailableAccountBalance(id1,newBalance1); + + _Bool results2=updateAvailableAccountBalance(id2,newBalance2); + + _Bool results3=updateAvailableAccountBalance(id3,newBalance3); + + + + do {if ((results1)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(29)));}} while(0); + + do {if ((results2)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(30)));}} while(0); + + do {if ((results3)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(31)));}} while(0); + + + +} diff --git a/build/test/dependencies/cmock.d b/build/test/dependencies/cmock.d index 7d1cf5d..58d1e9e 100644 --- a/build/test/dependencies/cmock.d +++ b/build/test/dependencies/cmock.d @@ -1,6 +1,6 @@ build/test/out/c/cmock.o: \ - /var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.c \ - /var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.h \ - /var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock_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 + /Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.c \ + /Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.h \ + /Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock_internals.h \ + /Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h diff --git a/build/test/dependencies/force_build b/build/test/dependencies/force_build deleted file mode 100644 index e69de29..0000000 diff --git a/build/test/dependencies/mainMenu.d b/build/test/dependencies/mainMenu.d deleted file mode 100644 index fbd8a70..0000000 --- a/build/test/dependencies/mainMenu.d +++ /dev/null @@ -1 +0,0 @@ -build/test/out/c/mainMenu.o: src/mainMenu.c src/mainMenu.h diff --git a/build/test/dependencies/test_mainMenu.d b/build/test/dependencies/test_mainMenu.d deleted file mode 100644 index 5ee8500..0000000 --- a/build/test/dependencies/test_mainMenu.d +++ /dev/null @@ -1,4 +0,0 @@ -build/test/out/c/test_mainMenu.o: tests/test_mainMenu.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/mainMenu.h diff --git a/build/test/dependencies/test_mainMenu_runner.d b/build/test/dependencies/test_mainMenu_runner.d deleted file mode 100644 index 0ac0cdd..0000000 --- a/build/test/dependencies/test_mainMenu_runner.d +++ /dev/null @@ -1,4 +0,0 @@ -build/test/out/c/test_mainMenu_runner.o: \ - build/test/runners/test_mainMenu_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 diff --git a/build/test/dependencies/test_updateCustomerAccountBalance.d b/build/test/dependencies/test_updateCustomerAccountBalance.d new file mode 100644 index 0000000..506a323 --- /dev/null +++ b/build/test/dependencies/test_updateCustomerAccountBalance.d @@ -0,0 +1,5 @@ +build/test/out/c/test_updateCustomerAccountBalance.o: \ + tests/test_updateCustomerAccountBalance.c \ + /Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ + src/updateCustomerAccountBalance.h diff --git a/build/test/dependencies/test_updateCustomerAccountBalance_runner.d b/build/test/dependencies/test_updateCustomerAccountBalance_runner.d new file mode 100644 index 0000000..e38698a --- /dev/null +++ b/build/test/dependencies/test_updateCustomerAccountBalance_runner.d @@ -0,0 +1,4 @@ +build/test/out/c/test_updateCustomerAccountBalance_runner.o: \ + build/test/runners/test_updateCustomerAccountBalance_runner.c \ + /Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h diff --git a/build/test/dependencies/unity.d b/build/test/dependencies/unity.d index e42504d..931f713 100644 --- a/build/test/dependencies/unity.d +++ b/build/test/dependencies/unity.d @@ -1,4 +1,4 @@ build/test/out/c/unity.o: \ - /var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.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 + /Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.c \ + /Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ + /Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h diff --git a/build/test/dependencies/updateCustomerAccountBalance.d b/build/test/dependencies/updateCustomerAccountBalance.d new file mode 100644 index 0000000..5f06f3b --- /dev/null +++ b/build/test/dependencies/updateCustomerAccountBalance.d @@ -0,0 +1,5 @@ +build/test/out/c/updateCustomerAccountBalance.o: \ + src/updateCustomerAccountBalance.c src/updateCustomerAccountBalance.h \ + src/currentCustomerAccountBalance.c \ + src/currentCustomerAccountBalance.h src/_file_information.h \ + src/lineReplacer.h diff --git a/build/test/out/c/cmock.o b/build/test/out/c/cmock.o index 76192ce..7a4b511 100644 Binary files a/build/test/out/c/cmock.o and b/build/test/out/c/cmock.o differ diff --git a/build/test/out/c/mainMenu.o b/build/test/out/c/mainMenu.o deleted file mode 100644 index 5666f15..0000000 Binary files a/build/test/out/c/mainMenu.o and /dev/null differ diff --git a/build/test/out/c/test_mainMenu.o b/build/test/out/c/test_mainMenu.o deleted file mode 100644 index c7879b1..0000000 Binary files a/build/test/out/c/test_mainMenu.o and /dev/null differ diff --git a/build/test/out/c/test_mainMenu_runner.o b/build/test/out/c/test_mainMenu_runner.o deleted file mode 100644 index 1666f41..0000000 Binary files a/build/test/out/c/test_mainMenu_runner.o and /dev/null differ diff --git a/build/test/out/c/test_updateCustomerAccountBalance.o b/build/test/out/c/test_updateCustomerAccountBalance.o new file mode 100644 index 0000000..fda3468 Binary files /dev/null and b/build/test/out/c/test_updateCustomerAccountBalance.o differ diff --git a/build/test/out/c/test_updateCustomerAccountBalance_runner.o b/build/test/out/c/test_updateCustomerAccountBalance_runner.o new file mode 100644 index 0000000..35fab4e Binary files /dev/null and b/build/test/out/c/test_updateCustomerAccountBalance_runner.o differ diff --git a/build/test/out/c/unity.o b/build/test/out/c/unity.o index ca4de30..cf2d7fe 100644 Binary files a/build/test/out/c/unity.o and b/build/test/out/c/unity.o differ diff --git a/build/test/out/c/updateCustomerAccountBalance.o b/build/test/out/c/updateCustomerAccountBalance.o new file mode 100644 index 0000000..3e002d0 Binary files /dev/null and b/build/test/out/c/updateCustomerAccountBalance.o differ diff --git a/build/test/out/test_mainMenu.out b/build/test/out/test_mainMenu.out deleted file mode 100755 index b4dffd7..0000000 Binary files a/build/test/out/test_mainMenu.out and /dev/null differ diff --git a/build/test/out/test_updateCustomerAccountBalance.out b/build/test/out/test_updateCustomerAccountBalance.out new file mode 100755 index 0000000..42268fb Binary files /dev/null and b/build/test/out/test_updateCustomerAccountBalance.out differ diff --git a/build/test/preprocess/files/test_mainMenu.c b/build/test/preprocess/files/test_mainMenu.c deleted file mode 100644 index c8bdf9f..0000000 --- a/build/test/preprocess/files/test_mainMenu.c +++ /dev/null @@ -1,299 +0,0 @@ -#include "src/mainMenu.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_agePermissionValidAge(void) - -{ - - - - - - - - - - int validAge[83]; - - - - - - _Bool - - validAgeResult[83]; - - - - int j=0; - - - - for(int i =18;i<101;i++){ - - - - validAge[j]= i; - - j++; - - } - - - - - - - - for(int i=0;i<83;i++){ - - - - validAgeResult[i] = agePermission(validAge[i]); - - } - - - - - - - - for(int i=0;i<83;i++){ - - - - do {if ((validAgeResult[i])) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(44)));}} while(0); - - - - } - - - -} - - - -void test_agePermissionInvalidAge(void) - -{ - - - - - - - - - - - - int invalidAge[117]; - - - - - - _Bool - - invalidAgeResult[117]; - - - - int j=0; - - - - for(int i =-100;i<18;i++){ - - - - invalidAge[j]= i; - - j++; - - } - - - - - - - - for(int i=0;i<117;i++){ - - - - invalidAgeResult[i] = agePermission(invalidAge[i]); - - - - } - - - - - - - - for(int i=0;i<117;i++){ - - - - do {if (!(invalidAgeResult[i])) {} else {UnityFail( ((" Expected FALSE Was TRUE")), (UNITY_UINT)((UNITY_UINT)(81)));}} while(0); - - - - } - - - -} - - - -void test_IsInteger(void) - -{ - - - - - - - - char* inputIsInteger[] = {"-10000000","-2000000","-354698","-66667","-7878","-987","-64","-5","0","1","2","10","201","333","4321","56974","698751","7878989","88954621" }; - - - - - - _Bool - - inputIsIntegerResult[19]; - - - - - - - - for(int i=0;i<19;i++) - - { - - - - inputIsIntegerResult[i] = checkIfInteger(inputIsInteger[i]); - - - - } - - - - - - - - for(int i=0;i<19;i++) - - { - - - - do {if ((inputIsIntegerResult[i])) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(110)));}} while(0); - - - - } - - - -} - - - -void test_IsNotInteger(void) - -{ - - - - - - - - char* inputIsNotInteger[] = {"0.15","3.141592653589793238","5.3254f","-6.264","-7878.3261","foo","Bar","FIZZ","buzZ","joHN","jAnE","foo-bar","3,15","2k13",""," ","-","+","/*-+.,/=" }; - - - - - - _Bool - - inputIsNotIntegerResult[19]; - - - - - - - - for(int i=0;i<19;i++) - - { - - - - inputIsNotIntegerResult[i] = checkIfInteger(inputIsNotInteger[i]); - - - - } - - - - - - - - for(int i=0;i<19;i++) - - { - - - - do {if (!(inputIsNotIntegerResult[i])) {} else {UnityFail( ((" Expected FALSE Was TRUE")), (UNITY_UINT)((UNITY_UINT)(139)));}} while(0); - - - - } - - - -} diff --git a/build/test/preprocess/files/test_updateCustomerAccountBalance.c b/build/test/preprocess/files/test_updateCustomerAccountBalance.c new file mode 100644 index 0000000..5b6d44a --- /dev/null +++ b/build/test/preprocess/files/test_updateCustomerAccountBalance.c @@ -0,0 +1,63 @@ +#include "src/updateCustomerAccountBalance.h" +#include "/Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" + + + + + + + + +void setUp(void) + +{ + +} + + + +void tearDown(void) + +{ + +} + + + +void test_updateAvailableAccountBalanceSuccess(void){ + + + + int id1 = 1234; + + int id2 = 1327; + + int id3 = 1666; + + + + int newBalance1=500; + + int newBalance2=800; + + int newBalance3=700; + + + + _Bool results1=updateAvailableAccountBalance(id1,newBalance1); + + _Bool results2=updateAvailableAccountBalance(id2,newBalance2); + + _Bool results3=updateAvailableAccountBalance(id3,newBalance3); + + + + do {if ((results1)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(29)));}} while(0); + + do {if ((results2)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(30)));}} while(0); + + do {if ((results3)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(31)));}} while(0); + + + +} diff --git a/build/test/preprocess/includes/test_mainMenu.c b/build/test/preprocess/includes/test_mainMenu.c deleted file mode 100644 index fb4dc93..0000000 --- a/build/test/preprocess/includes/test_mainMenu.c +++ /dev/null @@ -1,3 +0,0 @@ ---- -- "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" -- src/mainMenu.h diff --git a/build/test/preprocess/includes/test_updateCustomerAccountBalance.c b/build/test/preprocess/includes/test_updateCustomerAccountBalance.c new file mode 100644 index 0000000..2b0ad02 --- /dev/null +++ b/build/test/preprocess/includes/test_updateCustomerAccountBalance.c @@ -0,0 +1,3 @@ +--- +- "/Users/canhacioglu/.rbenv/versions/2.7.7/lib/ruby/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" +- src/updateCustomerAccountBalance.h diff --git a/build/test/results/test_mainMenu.pass b/build/test/results/test_mainMenu.pass deleted file mode 100644 index d5c35cb..0000000 --- a/build/test/results/test_mainMenu.pass +++ /dev/null @@ -1,30 +0,0 @@ ---- -:source: - :path: tests - :file: test_mainMenu.c -:successes: -- :test: test_agePermissionValidAge - :line: 15 - :message: '' - :unity_test_time: 0 -- :test: test_agePermissionInvalidAge - :line: 50 - :message: '' - :unity_test_time: 0 -- :test: test_IsInteger - :line: 87 - :message: '' - :unity_test_time: 0 -- :test: test_IsNotInteger - :line: 116 - :message: '' - :unity_test_time: 0 -:failures: [] -:ignores: [] -:counts: - :total: 4 - :passed: 4 - :failed: 0 - :ignored: 0 -:stdout: [] -:time: 0.0009556771256029606 diff --git a/build/test/runners/test_mainMenu_runner.c b/build/test/runners/test_updateCustomerAccountBalance_runner.c similarity index 75% rename from build/test/runners/test_mainMenu_runner.c rename to build/test/runners/test_updateCustomerAccountBalance_runner.c index 129fa89..887be8b 100644 --- a/build/test/runners/test_mainMenu_runner.c +++ b/build/test/runners/test_updateCustomerAccountBalance_runner.c @@ -10,10 +10,7 @@ char* GlobalOrderError; /*=======External Functions This Runner Calls=====*/ extern void setUp(void); extern void tearDown(void); -extern void test_agePermissionValidAge(void); -extern void test_agePermissionInvalidAge(void); -extern void test_IsInteger(void); -extern void test_IsNotInteger(void); +extern void test_updateAvailableAccountBalanceSuccess(void); /*=======Mock Management=====*/ @@ -77,11 +74,8 @@ static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE l /*=======MAIN=====*/ int main(void) { - UnityBegin("test_mainMenu.c"); - run_test(test_agePermissionValidAge, "test_agePermissionValidAge", 15); - run_test(test_agePermissionInvalidAge, "test_agePermissionInvalidAge", 50); - run_test(test_IsInteger, "test_IsInteger", 87); - run_test(test_IsNotInteger, "test_IsNotInteger", 116); + UnityBegin("test_updateCustomerAccountBalance.c"); + run_test(test_updateAvailableAccountBalanceSuccess, "test_updateAvailableAccountBalanceSuccess", 15); return UnityEnd(); } diff --git a/src/updateCustomerAccountBalance.c b/src/updateCustomerAccountBalance.c index 2040a6d..6986e08 100644 --- a/src/updateCustomerAccountBalance.c +++ b/src/updateCustomerAccountBalance.c @@ -8,19 +8,20 @@ void replaceLineInFile(const char* file_name, int line, const char* new_line){ printf("Error opening file!\n"); return; } - char current_string[1024]; + char current_string[100]; int current_line = 1; - char *temp_file_name = "temp.txt"; + char *temp_file_name = calloc(8+1, sizeof(char)); + temp_file_name = "temp.txt"; FILE* temp_file = fopen(temp_file_name, "w"); if (temp_file == NULL) { printf("Error creating temp file!\n"); fclose(file); return; } - while (fgets(current_string, sizeof(current_string), file) != NULL) { + while (fgets(current_string, sizeof(current_string),file) != NULL) { if (current_line == line) { - fprintf(temp_file, "%s", new_line); - fputs("\n", temp_file); + fprintf(temp_file, "%s\n", new_line); + //fputs("\n", temp_file); } else { fprintf(temp_file, "%s", current_string); } @@ -39,7 +40,7 @@ void replaceLineInFile(const char* file_name, int line, const char* new_line){ void replaceBalanceInString(float replacementBalance, int currentLine) { char newBalanceLine[MAX_LENGTH] = "balance="; char balance_as_string[MAX_LENGTH]; - sprintf(balance_as_string, "%g", replacementBalance); //converts replacement balance to string + sprintf(balance_as_string, "%f", replacementBalance); //converts replacement balance to string strcat(newBalanceLine, balance_as_string); replaceLineInFile("CustomerData.txt",currentLine,newBalanceLine); } @@ -48,17 +49,18 @@ bool updateAvailableAccountBalance(int user_id, float newBalance){ bool keep_reading = true; - char buffer[MAX_LENGTH]; - char stringID[MAX_LENGTH] = "ID="; - char user_id_as_string[MAX_LENGTH]; - char balance_String[MAX_LENGTH]; + char *buffer = malloc(MAX_LENGTH * sizeof(char)); + char *stringID = malloc(MAX_LENGTH * sizeof(char)); + stringID = "ID="; + char *user_id_as_string =malloc(MAX_LENGTH * sizeof(char)); + char *balance_String = malloc(MAX_LENGTH * sizeof(char)); int currentLine=0; sprintf(user_id_as_string, "%d", user_id); // converts user_id to string strcat(stringID, user_id_as_string); - FILE *file = fopen("CustomerData.txt", "r+"); - printf(stringID); + FILE *file = fopen("CustomerData.txt", "r"); + //printf(stringID); while(keep_reading) { fgets(buffer, MAX_LENGTH, file); currentLine++; @@ -78,4 +80,5 @@ bool updateAvailableAccountBalance(int user_id, float newBalance){ } fclose(file);; replaceBalanceInString(newBalance,currentLine); + return true; } diff --git a/tests/test_LoginCustomer.c b/tests/test_LoginCustomer.c deleted file mode 100644 index 610a847..0000000 --- a/tests/test_LoginCustomer.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include "LoginCustomer.h" -void setUp(){}; -void tearDown(){}; -void test_checkLogin() -{ - /*arrange*/ - bool expected_test_values_compute_to_true[] = {4==4,true==true, 1==1, false==false, 'z'=='z', '='=='=',0x1A==0x1A}; - int length_1 = sizeof(expected_test_values_compute_to_true)/sizeof(bool); - - bool expected_test_values_compute_to_false[] = {4!=4,true==false,1==0,false==true,'z'=='x','!'==')',0x1A==0x2B}; - int length_2 = sizeof(expected_test_values_compute_to_false)/sizeof(bool); - - /*act and assertions*/ - for(int i=0;i<7;++i) { - TEST_ASSERT_TRUE(checkLogin(expected_test_values_compute_to_true[i])); - } - for(int i=0;i<7;++i){ - TEST_ASSERT_FALSE(checkLogin(expected_test_values_compute_to_false[i])); - } -} diff --git a/tests/test_mainMenu.c b/tests/test_mainMenu.c deleted file mode 100644 index be1fb40..0000000 --- a/tests/test_mainMenu.c +++ /dev/null @@ -1,145 +0,0 @@ -#ifdef TEST - -#include "unity.h" - -#include "mainMenu.h" - -void setUp(void) -{ -} - -void tearDown(void) -{ -} - -void test_agePermissionValidAge(void) -{ - //Test case : 0 - - //Arrange - - int validAge[83]; - - bool validAgeResult[83]; - - int j=0; - - for(int i =18;i<101;i++){ - - validAge[j]= i; - j++; - } - - //Act - - for(int i=0;i<83;i++){ - - validAgeResult[i] = agePermission(validAge[i]); - } - - //Assert - - for(int i=0;i<83;i++){ - - TEST_ASSERT_TRUE(validAgeResult[i]); - - } - -} - -void test_agePermissionInvalidAge(void) -{ - - //Test case : 1 - - //Arrange - - int invalidAge[117]; - - bool invalidAgeResult[117]; - - int j=0; - - for(int i =-100;i<18;i++){ - - invalidAge[j]= i; - j++; - } - - //Act - - for(int i=0;i<117;i++){ - - invalidAgeResult[i] = agePermission(invalidAge[i]); - - } - - //Assert - - for(int i=0;i<117;i++){ - - TEST_ASSERT_FALSE(invalidAgeResult[i]); - - } - -} - -void test_IsInteger(void) -{ - - //Arrange - - char* inputIsInteger[] = {"-10000000","-2000000","-354698","-66667","-7878","-987","-64","-5","0","1","2","10","201","333","4321","56974","698751","7878989","88954621" }; - - bool inputIsIntegerResult[19]; - - //Act - - for(int i=0;i<19;i++) - { - - inputIsIntegerResult[i] = checkIfInteger(inputIsInteger[i]); - - } - - //Assert - - for(int i=0;i<19;i++) - { - - TEST_ASSERT_TRUE(inputIsIntegerResult[i]); - - } - -} - -void test_IsNotInteger(void) -{ - - //Arrange - - char* inputIsNotInteger[] = {"0.15","3.141592653589793238","5.3254f","-6.264","-7878.3261","foo","Bar","FIZZ","buzZ","joHN","jAnE","foo-bar","3,15","2k13",""," ","-","+","/*-+.,/=" }; - - bool inputIsNotIntegerResult[19]; - - //Act - - for(int i=0;i<19;i++) - { - - inputIsNotIntegerResult[i] = checkIfInteger(inputIsNotInteger[i]); - - } - - //Assert - - for(int i=0;i<19;i++) - { - - TEST_ASSERT_FALSE(inputIsNotIntegerResult[i]); - - } - -} - -#endif // TEST diff --git a/tests/test_updateCustomerAccountBalance.c b/tests/test_updateCustomerAccountBalance.c new file mode 100644 index 0000000..add1299 --- /dev/null +++ b/tests/test_updateCustomerAccountBalance.c @@ -0,0 +1,34 @@ +#ifdef TEST + +#include "unity.h" + +#include "updateCustomerAccountBalance.h" + +void setUp(void) +{ +} + +void tearDown(void) +{ +} + +void test_updateAvailableAccountBalanceSuccess(void){ + + int id1 = 1234; + int id2 = 1327; + int id3 = 1666; + + int newBalance1=500; + int newBalance2=800; + int newBalance3=700; + + bool results1=updateAvailableAccountBalance(id1,newBalance1); + bool results2=updateAvailableAccountBalance(id2,newBalance2); + bool results3=updateAvailableAccountBalance(id3,newBalance3); + + TEST_ASSERT_TRUE(results1); + TEST_ASSERT_TRUE(results2); + TEST_ASSERT_TRUE(results3); + +} +#endif