Browse Source

Merge branch 'feature/update-current-customer-account-balance' into feature/deposit-system

remotes/origin/feature/deposit-system
fdlt3817 2 years ago
parent
commit
d84314fa61
  1. 1
      .gitignore
  2. 6
      build-project.sh
  3. 3
      build/test/cache/defines_dependency.yml
  4. 20
      build/test/cache/input.yml
  5. 299
      build/test/cache/test_mainMenu.c
  6. 6
      build/test/dependencies/cmock.d
  7. 0
      build/test/dependencies/force_build
  8. 1
      build/test/dependencies/mainMenu.d
  9. 4
      build/test/dependencies/test_mainMenu.d
  10. 4
      build/test/dependencies/test_mainMenu_runner.d
  11. 4
      build/test/dependencies/unity.d
  12. BIN
      build/test/out/c/cmock.o
  13. BIN
      build/test/out/c/mainMenu.o
  14. BIN
      build/test/out/c/test_mainMenu.o
  15. BIN
      build/test/out/c/test_mainMenu_runner.o
  16. BIN
      build/test/out/c/unity.o
  17. BIN
      build/test/out/test_mainMenu.out
  18. 299
      build/test/preprocess/files/test_mainMenu.c
  19. 3
      build/test/preprocess/includes/test_mainMenu.c
  20. 30
      build/test/results/test_mainMenu.pass
  21. 12
      build/test/runners/test_mainMenu_runner.c
  22. 8
      project.yml
  23. 16
      src/CustomerData.txt
  24. BIN
      src/a.exe
  25. 50
      src/currentCustomerAccountBalance.c
  26. 7
      src/currentCustomerAccountBalance.h
  27. 6
      src/lineReplacer.h
  28. 93
      src/mainMenu.c
  29. 15
      src/mainMenu.h
  30. 83
      src/updateCustomerAccountBalance.c
  31. 11
      src/updateCustomerAccountBalance.h
  32. 3
      tests/build/test/cache/defines_dependency.yml
  33. 87
      tests/build/test/cache/test_LoginCustomer.c
  34. 3
      tests/build/test/dependencies/LoginCustomer.d
  35. 6
      tests/build/test/dependencies/cmock.d
  36. 4
      tests/build/test/dependencies/test_LoginCustomer.d
  37. 4
      tests/build/test/dependencies/test_LoginCustomer_runner.d
  38. 4
      tests/build/test/dependencies/unity.d
  39. BIN
      tests/build/test/out/c/LoginCustomer.o
  40. BIN
      tests/build/test/out/c/cmock.o
  41. BIN
      tests/build/test/out/c/test_LoginCustomer.o
  42. BIN
      tests/build/test/out/c/test_LoginCustomer_runner.o
  43. BIN
      tests/build/test/out/c/unity.o
  44. BIN
      tests/build/test/out/test_LoginCustomer.out
  45. 87
      tests/build/test/preprocess/files/test_LoginCustomer.c
  46. 3
      tests/build/test/preprocess/includes/test_LoginCustomer.c
  47. 18
      tests/build/test/results/test_LoginCustomer.pass
  48. 0
      tests/support/.gitkeep
  49. 0
      tests/test_LoginCustomer.c
  50. 145
      tests/test_mainMenu.c

1
.gitignore

@ -0,0 +1 @@
.DS_Store

6
build-project.sh

@ -0,0 +1,6 @@
clear
ceedling test:all
cd src/
gcc main.c mainMenu.c
./a.out
rm a.out

3
build/test/cache/defines_dependency.yml

@ -0,0 +1,3 @@
---
src/mainMenu.c:
- TEST

20
tests/build/test/cache/input.yml → build/test/cache/input.yml

@ -23,12 +23,12 @@
:artifacts: [] :artifacts: []
:paths: :paths:
:test: :test:
- "+:test/**"
- "-:test/support"
- "+:tests/**"
- "-:tests/support"
:source: :source:
- "/home/julius/Documents/Studium/Informatik/1. Semester/ProgMeth/Bankmanagement/bankmanagement-system/src/**"
- src/**
:support: :support:
- test/support
- tests/support
:include: [] :include: []
:libraries: [] :libraries: []
:test_toolchain_include: [] :test_toolchain_include: []
@ -77,10 +77,10 @@
:testfail: ".fail" :testfail: ".fail"
:dependencies: ".d" :dependencies: ".d"
:unity: :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: [] :defines: []
:cmock: :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: [] :defines: []
:includes: [] :includes: []
:mock_prefix: mock_ :mock_prefix: mock_
@ -99,7 +99,7 @@
:verbosity: 3 :verbosity: 3
:unity_helper: false :unity_helper: false
:cexception: :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: [] :defines: []
:test_runner: :test_runner:
:includes: [] :includes: []
@ -223,13 +223,13 @@
:arguments: [] :arguments: []
:plugins: :plugins:
:load_paths: :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: :enabled:
- stdout_pretty_tests_report - stdout_pretty_tests_report
- module_generator - module_generator
:display_raw_test_results: false :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: :gcov:
:reports: :reports:
- HtmlDetailed - HtmlDetailed

299
build/test/cache/test_mainMenu.c

@ -0,0 +1,299 @@
#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);
}
}

6
build/test/dependencies/cmock.d

@ -0,0 +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

0
tests/test/support/.gitkeep → build/test/dependencies/force_build

1
build/test/dependencies/mainMenu.d

@ -0,0 +1 @@
build/test/out/c/mainMenu.o: src/mainMenu.c src/mainMenu.h

4
build/test/dependencies/test_mainMenu.d

@ -0,0 +1,4 @@
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

4
build/test/dependencies/test_mainMenu_runner.d

@ -0,0 +1,4 @@
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

4
build/test/dependencies/unity.d

@ -0,0 +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

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

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

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

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

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

BIN
build/test/out/test_mainMenu.out

299
build/test/preprocess/files/test_mainMenu.c

@ -0,0 +1,299 @@
#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);
}
}

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

@ -0,0 +1,3 @@
---
- "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"
- src/mainMenu.h

30
build/test/results/test_mainMenu.pass

@ -0,0 +1,30 @@
---
: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

12
tests/build/test/runners/test_LoginCustomer_runner.c → build/test/runners/test_mainMenu_runner.c

@ -10,7 +10,10 @@ 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_checkLogin();
extern void test_agePermissionValidAge(void);
extern void test_agePermissionInvalidAge(void);
extern void test_IsInteger(void);
extern void test_IsNotInteger(void);
/*=======Mock Management=====*/ /*=======Mock Management=====*/
@ -74,8 +77,11 @@ static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE l
/*=======MAIN=====*/ /*=======MAIN=====*/
int main(void) int main(void)
{ {
UnityBegin("test_LoginCustomer.c");
run_test(test_checkLogin, "test_checkLogin", 5);
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);
return UnityEnd(); return UnityEnd();
} }

8
tests/project.yml → project.yml

@ -31,12 +31,12 @@
:paths: :paths:
:test: :test:
- +:test/**
- -:test/support
- +:tests/**
- -:tests/support
:source: :source:
- /home/julius/Documents/Studium/Informatik/1. Semester/ProgMeth/Bankmanagement/bankmanagement-system/src/**
- src/**
:support: :support:
- test/support
- tests/support
:libraries: [] :libraries: []
:defines: :defines:

16
src/CustomerData.txt

@ -3,4 +3,18 @@ ID=1234
forename=Max forename=Max
Surname=Mustermann Surname=Mustermann
password=example password=example
balance=0
balance=2000
1327=example
ID=1327
forename=Max
Surname=Mustermann
password=example
balance=1500
1666=example
ID=1666
forename=Max
Surname=Mustermann
password=example
balance=240

BIN
src/a.exe

50
src/currentCustomerAccountBalance.c

@ -0,0 +1,50 @@
#include "currentCustomerAccountBalance.h"
float fetchBalanceFromBalanceString(char balance_String[MAX_LENGTH]) {
float balance = 0;
char *token = strtok(balance_String, "="); // separates string to two parts
while (token != NULL) {
if (atoi(token) != 0) {
balance = atof(token); // converts string to float
break;
}
token = strtok(NULL, "=");
}
return balance;
}
float getAvailableAccountBalance(int user_id) {
bool keep_reading = true;
float availableBalance = 0;
char buffer[MAX_LENGTH];
char stringID[MAX_LENGTH] = "ID=";
char user_id_as_string[MAX_LENGTH];
char balance_String[MAX_LENGTH];
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");
while(keep_reading) {
fgets(buffer, MAX_LENGTH, file);
if (feof(file)) {
keep_reading = false;
}
else if(strstr(buffer, stringID)) {
fgets(buffer, MAX_LENGTH, file);
fgets(buffer, MAX_LENGTH, file);
fgets(buffer, MAX_LENGTH, file);
fgets(buffer, MAX_LENGTH, file);
strcpy(balance_String, buffer);
availableBalance = fetchBalanceFromBalanceString(balance_String);
keep_reading = false;
}
}
fclose(file);
return availableBalance;
}

7
src/currentCustomerAccountBalance.h

@ -0,0 +1,7 @@
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#define MAX_LENGTH 100
float getAvailableAccountBalance(int user_id);

6
src/lineReplacer.h

@ -0,0 +1,6 @@
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
void replaceLineInFile(const char* file_name, int line, const char* new_line); //replaces the line at "line" on the file "file_name", with the new line "new_line".

93
src/mainMenu.c

@ -0,0 +1,93 @@
#include"mainMenu.h"
bool agePermission(int age){
if(age >= 18)
{
return true;
}
else
{
return false;
}
}
bool checkIfInteger(char* input){
char *end_pointer;
strtol(input, &end_pointer, 10);
if (end_pointer == input || *end_pointer != '\0')
{
return false;
}
else
{
return true;
}
}
void ageInput(){
char input[20];
char* input_pointer;
long age;
printf("\nPlease specify your age : ");
scanf("%s",input);
if (checkIfInteger(input) == true )
{
age = strtol(input,&input_pointer,10);
if(agePermission(age)== true)
{
printf("Access granted!\n\n\n\n");
showMenu();
}
else if(agePermission(age)== false)
{
printf("You should be at least 18 years old to create a bank account!\n");
}
}
else
{
printf("input invalid! try again!\n");
}
}
void showMenu(){
printf("\t\t\t\t\t\t\t Welcome to Bank Manager!");
printf("\n\n\n\n\t\t\t\t\t\tPlease select one of the following functions!");
printf("\n\n\n\n\t\t\t\t\t\t ->Login as an existing costumer.");
printf("\n\n\t\t\t\t\t\t ->Register as a new costumer.");
printf("\n\n\t\t\t\t\t\t ->Login as an Employee.");
printf("\n\n\t\t\t\t\t\t\t\t ->Exit.\n");
printf("\n\n\n\n\n Selection :\n");
}

15
src/mainMenu.h

@ -0,0 +1,15 @@
#ifndef MAINMENU_H_
#define MAINMENU_H_
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
void showMenu();
void ageInput();
bool agePermission(int age);
bool checkIfInteger(char* input);
#endif

83
src/updateCustomerAccountBalance.c

@ -0,0 +1,83 @@
#include "updateCustomerAccountBalance.h"
#include "currentCustomerAccountBalance.c"
#include "lineReplacer.h"
void replaceLineInFile(const char* file_name, int line, const char* new_line){
FILE* file = fopen(file_name, "r");
if (file == NULL) {
printf("Error opening file!\n");
return;
}
char current_string[1024];
int current_line = 1;
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) {
if (current_line == line) {
fprintf(temp_file, "%s", new_line);
} else {
fprintf(temp_file, "%s", current_string);
}
current_line++;
}
fclose(file);
fclose(temp_file);
if(remove(file_name)!=0){
printf("could not remove the original file!");
} // Remove the original file
if(rename(temp_file_name, file_name)!=0){
printf("could not rename!");
} // Rename the temp file to the original file
}
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
strcat(newBalanceLine, balance_as_string);
replaceLineInFile("CustomerData.txt",currentLine,newBalanceLine);
}
bool updateAvailableAccountBalance(int user_id, float changeInBalance, bool positive){
bool keep_reading = true;
float availableBalance = 0;
char buffer[MAX_LENGTH];
char stringID[MAX_LENGTH] = "ID=";
char user_id_as_string[MAX_LENGTH];
char balance_String[MAX_LENGTH];
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);
while(keep_reading) {
fgets(buffer, MAX_LENGTH, file);
currentLine++;
if (feof(file)) {
keep_reading = false;
}
else if(strstr(buffer, stringID)) { //found the customer
fgets(buffer, MAX_LENGTH, file);
fgets(buffer, MAX_LENGTH, file);
fgets(buffer, MAX_LENGTH, file);
fgets(buffer, MAX_LENGTH, file);
strcpy(balance_String, buffer);
currentLine+=4;
availableBalance = fetchBalanceFromBalanceString(balance_String);
keep_reading = false;
}
}
fclose(file);
float newBalance = (positive) ? availableBalance+changeInBalance : availableBalance-changeInBalance;
replaceBalanceInString(newBalance,currentLine);
}

11
src/updateCustomerAccountBalance.h

@ -0,0 +1,11 @@
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#define MAX_LENGTH 100
bool updateAvailableAccountBalance(int user_id, float changeInBalance, bool positive);
void replaceBalanceInString(float replacementBalance, int currentLine);

3
tests/build/test/cache/defines_dependency.yml

@ -1,3 +0,0 @@
---
"/home/julius/Documents/Studium/Informatik/1. Semester/ProgMeth/Bankmanagement/bankmanagement-system/src/LoginCustomer.c":
- TEST

87
tests/build/test/cache/test_LoginCustomer.c

@ -1,87 +0,0 @@
#include "Semester/ProgMeth/Bankmanagement/bankmanagement-system/src/LoginCustomer.h"
#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"
void setUp(){};
void tearDown(){};
void test_checkLogin()
{
_Bool
expected_test_values_compute_to_true[] = {4==4,
1
==
1
, 1==1,
0
==
0
, '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,
1
==
0
,1==0,
0
==
1
,'z'=='x','!'==')',0x1A==0x2B};
int length_2 = sizeof(expected_test_values_compute_to_false)/sizeof(
_Bool
);
for(int i=0;i<7;++i) {
do {if ((checkLogin(expected_test_values_compute_to_true[i]))) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(16)));}} while(0);
}
for(int i=0;i<7;++i){
do {if (!(checkLogin(expected_test_values_compute_to_false[i]))) {} else {UnityFail( ((" Expected FALSE Was TRUE")), (UNITY_UINT)((UNITY_UINT)(19)));}} while(0);
}
}

3
tests/build/test/dependencies/LoginCustomer.d

@ -1,3 +0,0 @@
build/test/out/c/LoginCustomer.o: \
/home/julius/Documents/Studium/Informatik/1.\ Semester/ProgMeth/Bankmanagement/bankmanagement-system/src/LoginCustomer.c \
/home/julius/Documents/Studium/Informatik/1.\ Semester/ProgMeth/Bankmanagement/bankmanagement-system/src/LoginCustomer.h

6
tests/build/test/dependencies/cmock.d

@ -1,6 +0,0 @@
build/test/out/c/cmock.o: \
/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.c \
/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.h \
/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock_internals.h \
/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

4
tests/build/test/dependencies/test_LoginCustomer.d

@ -1,4 +0,0 @@
build/test/out/c/test_LoginCustomer.o: test/test_LoginCustomer.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 \
/home/julius/Documents/Studium/Informatik/1.\ Semester/ProgMeth/Bankmanagement/bankmanagement-system/src/LoginCustomer.h

4
tests/build/test/dependencies/test_LoginCustomer_runner.d

@ -1,4 +0,0 @@
build/test/out/c/test_LoginCustomer_runner.o: \
build/test/runners/test_LoginCustomer_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

4
tests/build/test/dependencies/unity.d

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

BIN
tests/build/test/out/c/LoginCustomer.o

BIN
tests/build/test/out/c/cmock.o

BIN
tests/build/test/out/c/test_LoginCustomer.o

BIN
tests/build/test/out/c/test_LoginCustomer_runner.o

BIN
tests/build/test/out/c/unity.o

BIN
tests/build/test/out/test_LoginCustomer.out

87
tests/build/test/preprocess/files/test_LoginCustomer.c

@ -1,87 +0,0 @@
#include "Semester/ProgMeth/Bankmanagement/bankmanagement-system/src/LoginCustomer.h"
#include "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"
void setUp(){};
void tearDown(){};
void test_checkLogin()
{
_Bool
expected_test_values_compute_to_true[] = {4==4,
1
==
1
, 1==1,
0
==
0
, '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,
1
==
0
,1==0,
0
==
1
,'z'=='x','!'==')',0x1A==0x2B};
int length_2 = sizeof(expected_test_values_compute_to_false)/sizeof(
_Bool
);
for(int i=0;i<7;++i) {
do {if ((checkLogin(expected_test_values_compute_to_true[i]))) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(16)));}} while(0);
}
for(int i=0;i<7;++i){
do {if (!(checkLogin(expected_test_values_compute_to_false[i]))) {} else {UnityFail( ((" Expected FALSE Was TRUE")), (UNITY_UINT)((UNITY_UINT)(19)));}} while(0);
}
}

3
tests/build/test/preprocess/includes/test_LoginCustomer.c

@ -1,3 +0,0 @@
---
- "/var/lib/gems/2.7.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h"
- Semester/ProgMeth/Bankmanagement/bankmanagement-system/src/LoginCustomer.h

18
tests/build/test/results/test_LoginCustomer.pass

@ -1,18 +0,0 @@
---
:source:
:path: test
:file: test_LoginCustomer.c
:successes:
- :test: test_checkLogin
:line: 5
:message: ''
:unity_test_time: 0
:failures: []
:ignores: []
:counts:
:total: 1
:passed: 1
:failed: 0
:ignored: 0
:stdout: []
:time: 0.001912861000164412

0
tests/support/.gitkeep

0
tests/test/test_LoginCustomer.c → tests/test_LoginCustomer.c

145
tests/test_mainMenu.c

@ -0,0 +1,145 @@
#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
Loading…
Cancel
Save