/
PasswordGenTest.java
34 lines (27 loc) · 1.03 KB
/
PasswordGenTest.java
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
package com.thealgorithms.others;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
public class PasswordGenTest {
@Test
public void failGenerationWithSameMinMaxLengthTest() {
int length = 10;
assertThrows(IllegalArgumentException.class, () -> { PasswordGen.generatePassword(length, length); });
}
@Test
public void generateOneCharacterPassword() {
String tempPassword = PasswordGen.generatePassword(1, 2);
assertTrue(tempPassword.length() == 1);
}
@Test
public void failGenerationWithMinLengthSmallerThanMaxLengthTest() {
int minLength = 10;
int maxLength = 5;
assertThrows(IllegalArgumentException.class, () -> { PasswordGen.generatePassword(minLength, maxLength); });
}
@Test
public void generatePasswordNonEmptyTest() {
String tempPassword = PasswordGen.generatePassword(8, 16);
assertTrue(tempPassword.length() != 0);
}
}