-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainTest.java
65 lines (54 loc) · 2.07 KB
/
MainTest.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
// SPDX-License-Identifier: AGPL-3.0-or-later
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.*;
import tests.Redirect;
import java.io.IOException;
import java.util.Random;
@Slf4j
public final class MainTest {
private static final String DATA_PATH = "resources/";
private static final long begin_time = System.currentTimeMillis();
private static final Random random = new Random();
@AfterAll
public static void last_one() throws IOException {
log.info("cost {} ms\n", System.currentTimeMillis() - begin_time);
}
@BeforeEach
public void beforeEach(TestInfo testInfo) {
log.info("{} begin", testInfo.getDisplayName());
}
@AfterEach
public void afterEach(TestInfo testInfo) {
log.info("{} end", testInfo.getDisplayName());
}
@Test
public void test_0() {
Assertions.assertEquals(0xFFFFFFFF, Main.cal(new int[]{0xFFFFFFFE, 1}));
Assertions.assertEquals(0x00000001, Main.cal(new int[]{0x00000000, 1}));
Assertions.assertEquals(0xFFFFFFF0, Main.cal(new int[]{0xFFFFFFEF, 1}));
}
@Test
public void test_1() {
Assertions.assertEquals(0xFFFFFFFE, Main.cal(new int[]{0xFFFFFFFF, -1}));
Assertions.assertEquals(0xFFFFFFFE, Main.cal(new int[]{0xFFFFFFFF, -1}));
Assertions.assertEquals(0xFFFFFFEE, Main.cal(new int[]{0xFFFFFFEF, -1}));
Assertions.assertEquals(0x12345678 << 1, Main.cal(new int[]{0x12345678, 0x12345678}));
}
@Test
public void test_2() {
for (int i = 0; i < 114; i++) {
int x = random.nextInt(0x3f3f3f3f);
int y = random.nextInt(0x3f3f3f3f);
Assertions.assertEquals(x + y, Main.cal(new int[]{x, y}));
}
}
@Test
public void test_3() throws IOException {
try (Redirect redirect = Redirect.from(DATA_PATH, "01.data.in", "")) {
Assertions.assertEquals(628, Main.cal(Main.read()));
}
try (Redirect redirect = Redirect.from(DATA_PATH, "01.data.in", "")) {
Assertions.assertEquals(628, Main.cal(Main.read()));
}
}
}