|
5 | 5 |
|
6 | 6 | public class Test_StringTool { |
7 | 7 |
|
| 8 | + @Test |
| 9 | + public void testIsMailAddress() { |
| 10 | + // Test valid email addresses that should pass |
| 11 | + Assert.assertTrue("Basic email should be valid", StringTool.isMailAddress("test@example.com")); |
| 12 | + Assert.assertTrue("Email with dot should be valid", StringTool.isMailAddress("test.person@example.com")); |
| 13 | + Assert.assertTrue("Email with dash should be valid", StringTool.isMailAddress("test-person@example.com")); |
| 14 | + |
| 15 | + // Test valid email addresses with plus character (Gmail-style aliases) |
| 16 | + Assert.assertTrue("Email with plus should be valid", StringTool.isMailAddress("test.person+tag@gmail.com")); |
| 17 | + Assert.assertTrue("Email with plus and number should be valid", StringTool.isMailAddress("user+123@domain.org")); |
| 18 | + Assert.assertTrue("Email with plus at end should be valid", StringTool.isMailAddress("test+@example.com")); |
| 19 | + |
| 20 | + // Test invalid email addresses |
| 21 | + Assert.assertFalse("Null should be invalid", StringTool.isMailAddress(null)); |
| 22 | + Assert.assertFalse("Empty string should be invalid", StringTool.isMailAddress("")); |
| 23 | + Assert.assertFalse("String without @ should be invalid", StringTool.isMailAddress("testexample.com")); |
| 24 | + Assert.assertFalse("String without domain should be invalid", StringTool.isMailAddress("test@")); |
| 25 | + Assert.assertFalse("String without local part should be invalid", StringTool.isMailAddress("@example.com")); |
| 26 | + Assert.assertFalse("String with single char TLD should be invalid", StringTool.isMailAddress("test@example.c")); |
| 27 | + Assert.assertFalse("String with too long TLD should be invalid", StringTool.isMailAddress("test@example.toolongext")); |
| 28 | + } |
| 29 | + |
8 | 30 | @Test |
9 | 31 | public void testStringCompare() { |
10 | 32 |
|
|
0 commit comments