-
Notifications
You must be signed in to change notification settings - Fork 2
/
WeekdayCalculatorTest.java
83 lines (68 loc) · 2.07 KB
/
WeekdayCalculatorTest.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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
package com.lezurex.overcomplicated;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.Calendar;
import java.util.Date;
import static org.junit.jupiter.api.Assertions.*;
public class WeekdayCalculatorTest {
private static int weekday;
@BeforeAll
public static void before() {
final Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
weekday = calendar.get(Calendar.DAY_OF_WEEK);
}
@Test
public void testIsMonday() {
if(weekday == Calendar.MONDAY)
assertTrue(WeekdayCalculator.isMonday());
else
assertFalse(WeekdayCalculator.isMonday());
}
@Test
public void testIsTuesday() {
if(weekday == Calendar.TUESDAY)
assertTrue(WeekdayCalculator.isTuesday());
else
assertFalse(WeekdayCalculator.isTuesday());
}
@Test
public void testIsWednesday() {
if(weekday == Calendar.WEDNESDAY)
assertTrue(WeekdayCalculator.isWednesday());
else
assertFalse(WeekdayCalculator.isWednesday());
}
@Test
public void testIsThursday() {
if(weekday == Calendar.THURSDAY)
assertTrue(WeekdayCalculator.isThursday());
else
assertFalse(WeekdayCalculator.isThursday());
}
@Test
public void testIsFriday() {
if(weekday == Calendar.FRIDAY)
assertTrue(WeekdayCalculator.isFriday());
else
assertFalse(WeekdayCalculator.isFriday());
}
@Test
public void testIsSaturday() {
if(weekday == Calendar.SATURDAY)
assertTrue(WeekdayCalculator.isSaturday());
else
assertFalse(WeekdayCalculator.isSaturday());
}
@Test
public void testIsSunday() {
if(weekday == Calendar.SUNDAY)
assertTrue(WeekdayCalculator.isSunday());
else
assertFalse(WeekdayCalculator.isSunday());
}
@Test
public void testFun() {
assertThrows(StackOverflowError.class, WeekdayCalculator::fun);
}
}