-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCpfValidatorTest.java
More file actions
70 lines (58 loc) · 1.56 KB
/
Copy pathCpfValidatorTest.java
File metadata and controls
70 lines (58 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import static io.github.multiform_validator.identity.CpfValidator.cpfIsValid;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class CpfValidatorTest {
@Test
void testValidCpf() {
assertTrue(cpfIsValid("12345678909"));
assertTrue(cpfIsValid("11144477735"));
}
@Test
void testInvalidCpf() {
assertFalse(cpfIsValid("12345678901"));
assertFalse(cpfIsValid("11144477736"));
}
@Test
void testNullCpf() {
assertThrows(NullPointerException.class, () -> cpfIsValid(null));
}
@Test
void testEmptyCpf() {
assertFalse(cpfIsValid(""));
}
@Test
void testInvalidFormatCpf() {
assertFalse(cpfIsValid("123.456.789-19"));
assertFalse(cpfIsValid("1114447773A"));
}
@Test
void testInvalidLengthCpf() {
assertFalse(cpfIsValid("1234567890"));
assertFalse(cpfIsValid("111444777350"));
}
@Test
void testInvalidCpfWithLetters() {
assertFalse(cpfIsValid("1234567890A"));
assertFalse(cpfIsValid("1114447773A"));
}
@Test
void testInvalidCpfWithSpecialCharacters() {
assertFalse(cpfIsValid("1234567890@"));
assertFalse(cpfIsValid("1114447773@"));
}
@Test
void testInvalidCpfWithSpaces() {
assertFalse(cpfIsValid("1234567890 "));
assertFalse(cpfIsValid("1114447773 "));
}
@Test
void testAllDigitsAreEqual() {
assertFalse(cpfIsValid("00000000000"));
assertFalse(cpfIsValid("11111111111"));
}
@Test
void testInvalidCpfWithSpecialCharactersAndLetters() {
assertFalse(cpfIsValid("1234567890@"));
assertFalse(cpfIsValid("1114447773A"));
}
}