-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_2.java
More file actions
32 lines (27 loc) · 1.1 KB
/
task_2.java
File metadata and controls
32 lines (27 loc) · 1.1 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
import org.junit.Test;
import static org.junit.Assert.assertEquals;
class Program {
public boolean checkIsAdult(int age) {
return age >= 18;
}
}
public class ProgramTest {
@Test
public void checkIsAdultWhenAgeIsMoreThan18True() {
Program program = new Program();
boolean isAdult = program.checkIsAdult(19);
assertEquals("Должно вернуться true, так как пользователь совершеннолетний", true, isAdult);
}
@Test
public void checkIsAdultWhenAgeIsLessThan18False() {
Program program = new Program();
boolean isAdult = program.checkIsAdult(17);
assertEquals("Должно вернуться false, так как пользователю меньше 18 лет", false, isAdult);
}
@Test
public void checkIsAdultWhenAgeIs18True() {
Program program = new Program();
boolean isAdult = program.checkIsAdult(18);
assertEquals("Должно вернуться true, так как пользователю ровно 18 лет", true, isAdult);
}
}