Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to student #160

Merged

Conversation

feifeiraindrops
Copy link
Collaborator

No description provided.

@feifeiraindrops feifeiraindrops added this to the v1.4 milestone Nov 11, 2023
@feifeiraindrops feifeiraindrops self-assigned this Nov 11, 2023
Copy link

codecov bot commented Nov 11, 2023

Codecov Report

Merging #160 (75d8862) into master (371b097) will increase coverage by 2.12%.
Report is 13 commits behind head on master.
The diff coverage is 58.82%.

@@             Coverage Diff              @@
##             master     #160      +/-   ##
============================================
+ Coverage     28.25%   30.38%   +2.12%     
- Complexity      378      425      +47     
============================================
  Files           123      126       +3     
  Lines          3221     3229       +8     
  Branches        367      370       +3     
============================================
+ Hits            910      981      +71     
+ Misses         2212     2151      -61     
+ Partials         99       97       -2     
Files Coverage Δ
...main/java/seedu/address/model/student/Student.java 81.69% <100.00%> (+16.47%) ⬆️
...in/java/seedu/address/model/student/StudentId.java 100.00% <100.00%> (+14.28%) ⬆️
.../student/exceptions/DuplicateStudentException.java 100.00% <100.00%> (ø)
...l/student/exceptions/StudentNotFoundException.java 100.00% <100.00%> (ø)
...java/seedu/address/storage/JsonAdaptedStudent.java 0.00% <0.00%> (ø)
...seedu/address/storage/JsonAdaptedStudentScore.java 0.00% <0.00%> (ø)
...dentscore/exceptions/DuplicateScoresException.java 0.00% <0.00%> (ø)
...seedu/address/model/student/UniqueStudentList.java 55.31% <52.63%> (+22.34%) ⬆️

... and 5 files with indirect coverage changes

Copy link
Collaborator

@siqirua siqirua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

this.sid = sid;
}

/**
* Returns true if a given string is a valid name.
*/
public static boolean isValidName(String test) {
public static boolean isValidSid(String test) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how you rename the variable name !

Comment on lines +26 to +64
assertFalse(StudentEmail.isValidEmail("")); // empty string
assertFalse(StudentEmail.isValidEmail(" ")); // spaces only

// missing parts
assertFalse(StudentEmail.isValidEmail("@example.com")); // missing local part
assertFalse(StudentEmail.isValidEmail("peterjackexample.com")); // missing '@' symbol
assertFalse(StudentEmail.isValidEmail("peterjack@")); // missing domain name

// invalid parts
assertFalse(StudentEmail.isValidEmail("peterjack@-")); // invalid domain name
assertFalse(StudentEmail.isValidEmail("peterjack@exam_ple.com")); // underscore in domain name
assertFalse(StudentEmail.isValidEmail("peter [email protected]")); // spaces in local part
assertFalse(StudentEmail.isValidEmail("peterjack@exam ple.com")); // spaces in domain name
assertFalse(StudentEmail.isValidEmail(" [email protected]")); // leading space
assertFalse(StudentEmail.isValidEmail("[email protected] ")); // trailing space
assertFalse(StudentEmail.isValidEmail("peterjack@@example.com")); // double '@' symbol
assertFalse(StudentEmail.isValidEmail("peter@[email protected]")); // '@' symbol in local part
assertFalse(StudentEmail.isValidEmail("[email protected]")); // local part starts with a hyphen
assertFalse(StudentEmail.isValidEmail("[email protected]")); // local part ends with a hyphen
assertFalse(StudentEmail.isValidEmail("[email protected]")); // local part has two consecutive periods
assertFalse(StudentEmail.isValidEmail("peterjack@example@com")); // '@' symbol in domain name
assertFalse(StudentEmail.isValidEmail("[email protected]")); // domain name starts with a period
assertFalse(StudentEmail.isValidEmail("[email protected].")); // domain name ends with a period
assertFalse(StudentEmail.isValidEmail("[email protected]")); // domain name starts with a hyphen
assertFalse(StudentEmail.isValidEmail("[email protected]")); // domain name ends with a hyphen
assertFalse(StudentEmail.isValidEmail("[email protected]")); // top level domain has less than two chars

// valid email
assertTrue(StudentEmail.isValidEmail("[email protected]")); // underscore in local part
assertTrue(StudentEmail.isValidEmail("[email protected]")); // period in local part
assertTrue(StudentEmail.isValidEmail("[email protected]")); // '+' symbol in local part
assertTrue(StudentEmail.isValidEmail("[email protected]")); // hyphen in local part
assertTrue(StudentEmail.isValidEmail("a@bc")); // minimal
assertTrue(StudentEmail.isValidEmail("test@localhost")); // alphabets only
assertTrue(StudentEmail.isValidEmail("123@145")); // numeric local part and domain name
assertTrue(StudentEmail.isValidEmail("[email protected]")); // mixture of alphanumeric and special characters
assertTrue(StudentEmail.isValidEmail("[email protected]")); // long domain name
assertTrue(StudentEmail.isValidEmail("[email protected]")); // long local part
assertTrue(StudentEmail.isValidEmail("[email protected]")); // more than one period in domain
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how you design the test cases!

@siqirua siqirua merged commit d031b4c into AY2324S1-CS2103T-W08-2:master Nov 11, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants