jevancjk / ICT2201-P1-4

0 stars 0 forks source link

5.1.2 createUser #67

Open YapJiaHao opened 1 year ago

YapJiaHao commented 1 year ago

deadline 25/11/22

jevancjk commented 1 year ago

PSEUDOCODE for createUser()

1 function createUser(email, password, pwdConfirm, role) { 2 input email 3 input password 4 input pwdConfirm 5 input role 6 if (email or password or pwdConfirm or role is NULL) { 7 alert(“Please fill in accordingly”) } 8 else { 9 if (password and pwdConfirm do not match) { 10 alert(“Your password confirmation does not match your password”) } 11 else { 12 Successful user creation } } 13 }// code exit

Control flow graph

Image

joash2808 commented 1 year ago

Image

1 function createUser(email, password, pwdConfirm, role) { 2 Sanitize user input 3 Pull from database users email and put in a list 4 for loop where number of loops equals to list size { 5 if(email is equivalent to another email in list) { 6 alert(“Email already in use”) 7 return } } 8 if (email or password or pwdConfirm or role is NULL) { 9 alert(“Please fill in accordingly”) 10 return } 11 if (email or password or pwdConfirm or role input is not valid) { 12 alert(“Please fill in accordingly”) 13 return } 14 else { 15 if (password != pwdConfirm) { 16 alert(“Your password confirmation does not match your
password”) 17 return } 18 else { 19 Send credentials to database to update 20 Display success message } } 21 }// code exit

Number of edges: 25, Number of nodes: 21 Cyclomatic complexity: 25-21+2(1) = 6 Basis Path / Control Flow Testing All possible paths: 1-2-3-4-5-4-5-8-11-14-15-18-19-20-21 1-2-3-4-5-4-5-8-11-14-15-16-17-21 1-2-3-4-5-4-5-8-11-12-13-21 1-2-3-4-5-4-5-8-9-10-21 1-2-3-4-5-4-5-6-7-21 1-2-3-4-5-6-7-21 Test cases for respective paths: email=managerA@coachco.com, password=abc123, pwdConfirm=abc123, role=manager email=managerA@coachco.com, password=abc123, pwdConfirm=def456, role=manager email=ict2x01@sit.com, password=asdfghjkl, pwdConfirm=asdfghjkl, role=zxcvbnm email=, password=abc123, pwdConfirm=abc123, role=staff email=, password=abc123, pwdConfirm=abc123, role=staff email=, password=abc123, pwdConfirm=abc123, role=staff

updated create user function over here, please check