From 69a25cfa6aaa9f2228154b0656d2cefa03717d89 Mon Sep 17 00:00:00 2001 From: fdai7207 Date: Mon, 6 Feb 2023 04:51:26 +0100 Subject: [PATCH] implemented unit tests for the new function verifyPassword() and changed the .txt files name while adding a new .txt file for personal emoyees data. --- build-project.sh | 4 +- src/createEmployeeAccount.c | 50 ++++++++++++------- src/createEmployeeAccount.h | 1 + src/employeeLogin.c | 2 +- ...eList.txt => employeesCredentialsList.txt} | 5 ++ src/employeesData.txt | 36 +++++++++++++ tests/test_createEmployeeAccount.c | 46 +++++++++++++++++ 7 files changed, 122 insertions(+), 22 deletions(-) rename src/{employeeList.txt => employeesCredentialsList.txt} (96%) create mode 100644 src/employeesData.txt diff --git a/build-project.sh b/build-project.sh index 9b064c8..ab820fc 100755 --- a/build-project.sh +++ b/build-project.sh @@ -14,8 +14,8 @@ ceedling test:all cd src/ -sed '/John Doe/,$d' employeeList.txt > temp.txt -mv temp.txt employeeList.txt +sed '/John Doe/,$d' employeesCredentialsList.txt > temp.txt +mv temp.txt employeesCredentialsList.txt # backup files for file in employeeLogin.c mainMenu.c createEmployeeAccount.c; do cp "$file" "$file.bak" diff --git a/src/createEmployeeAccount.c b/src/createEmployeeAccount.c index f2dcd1a..4af6f04 100644 --- a/src/createEmployeeAccount.c +++ b/src/createEmployeeAccount.c @@ -2,20 +2,21 @@ #include "createEmployeeAccount.h" - -int StringLengthCounter(char* string) +bool isValidEmployeeID(const char* employeeId, int maximumStringLength) { - int characterCounter = 0; - int i = 0; - while(string[i] !='\0') + int employeeIdLength = strlen(employeeId); + + for(int i=0;i