-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_3.java
More file actions
36 lines (31 loc) · 1.17 KB
/
task_3.java
File metadata and controls
36 lines (31 loc) · 1.17 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
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection;
import static org.junit.Assert.assertEquals;
@RunWith(Parameterized.class)
public class CheckIsAdultTest {
private final int age;
private final boolean result;
public CheckIsAdultTest(int age, boolean result) {
this.age = age;
this.result = result;
}
@Parameterized.Parameters
public static Object[][] getTextData() {
return new Object[][] {
{17, false}, // младше 18 лет - несовершеннолетний
{18, true}, // ровно 18 лет - совершеннолетний
{19, true}, // старше 18 лет - совершеннолетний
{21, true} // 21 год - совершеннолетний
};
}
@Test
public void checkIsAdultWhenAgeThenResult() {
Program program = new Program();
boolean isAdult = program.checkIsAdult(age);
assertEquals("Для возраста " + age + " ожидается результат: " +
result, result, isAdult);
}
}