forked from NASU41/AtCoderLibraryForJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
41 lines (37 loc) · 1.36 KB
/
Test.java
File metadata and controls
41 lines (37 loc) · 1.36 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
37
38
39
40
41
package test;
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class Test {
static final int TEST_CASE_NUM = Gen.TESTCASE_NUM;
public static void main(String[] args) {
for (int i = 0; i < TEST_CASE_NUM; i++) {
String answerFileName = String.format("LazySegTree/test/answer/answer_%d", i);
String outputFileName = String.format("LazySegTree/test/out/out_%d", i);
try (Scanner scAns = new Scanner(new File(answerFileName))) {
try (Scanner scSlv = new Scanner(new File(outputFileName))) {
test(scAns, scSlv);
} catch (AssertionError e) {
System.err.printf("Error in test %d", i);
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
}
}
public static void test(Scanner scAns, Scanner scSlv) {
int line = 1;
while (scAns.hasNext() && scSlv.hasNext()) {
String ans = scAns.next();
String slv = scSlv.next();
if (!ans.equals(slv)) {
throw new AssertionError(
String.format("Filed at line %d.\n\texpected: %s\n\tactual: %s", line, ans, slv)
);
}
line++;
}
}
}