-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilesTests.java
More file actions
30 lines (22 loc) · 840 Bytes
/
FilesTests.java
File metadata and controls
30 lines (22 loc) · 840 Bytes
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
package com.github.hubertwo.playground.java12.files;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import static org.assertj.core.api.Assertions.assertThat;
class FilesTests {
@Test
void mismatch() throws IOException {
// ABCD
Path path1 = Paths.get("src/test/resources/java12/files/mismatch/File1.txt");
// ABED
Path path2 = Paths.get("src/test/resources/java12/files/mismatch/File2.txt");
long actualMismatchPosition = Files.mismatch(path1, path2);
// Confirm that files have the same size
assertThat(Files.size(path1))
.isGreaterThan(0)
.isEqualTo(Files.size(path2));
assertThat(actualMismatchPosition).isEqualTo(2);
}
}