Skip to content

Commit 8dfde28

Browse files
author
Brian Burkhalter
committed
8315485: (fs) Move java/nio/file/Path/Misc.java tests into java/nio/file/Path/PathOps.java
Reviewed-by: alanb
1 parent 3c743cf commit 8dfde28

File tree

2 files changed

+61
-91
lines changed

2 files changed

+61
-91
lines changed

test/jdk/java/nio/file/Path/Misc.java

-88
This file was deleted.

test/jdk/java/nio/file/Path/PathOps.java

+61-3
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,22 @@
2222
*/
2323

2424
/* @test
25-
* @bug 4313887 6838333 6925932 7006126 8037945 8072495 8140449 8254876 8262742
26-
* 8298478
25+
* @bug 4313887 6838333 6925932 7006126 7029979 8037945 8072495 8140449
26+
* 8254876 8262742 8298478
2727
* @summary Unit test for java.nio.file.Path path operations
28+
* @library .. /test/lib
29+
* @build jdk.test.lib.Platform
30+
* @run main PathOps
2831
*/
2932

33+
import java.io.File;
3034
import java.nio.file.FileSystems;
3135
import java.nio.file.InvalidPathException;
3236
import java.nio.file.Path;
3337
import java.nio.file.Paths;
3438

39+
import jdk.test.lib.Platform;
40+
3541
public class PathOps {
3642

3743
static final java.io.PrintStream out = System.out;
@@ -239,6 +245,34 @@ PathOps normalize(String expected) {
239245
return this;
240246
}
241247

248+
PathOps equals(String other) {
249+
out.format("test equals %s\n", other);
250+
checkPath();
251+
252+
Path that = Path.of(other);
253+
check(that, path.toString());
254+
check(path.hashCode() == that.hashCode(), true);
255+
256+
return this;
257+
}
258+
259+
PathOps notEquals(Object other) {
260+
out.format("test not equals %s\n", other);
261+
checkPath();
262+
check(path.equals(other), false);
263+
264+
return this;
265+
}
266+
267+
PathOps toFile() {
268+
out.println("check toFile");
269+
checkPath();
270+
File file = path.toFile();
271+
check(file.toString(), path.toString());
272+
check(file.toPath().equals(path), true);
273+
return this;
274+
}
275+
242276
PathOps string(String expected) {
243277
out.println("check string representation");
244278
checkPath();
@@ -1444,6 +1478,18 @@ static void doWindowsTests() {
14441478
.parent(null)
14451479
.name(null);
14461480

1481+
// equals
1482+
test("this")
1483+
.equals("this")
1484+
.notEquals(Path.of("that"))
1485+
.notEquals(null)
1486+
.notEquals(new Object())
1487+
.equals(Path.of("This"));
1488+
1489+
// toFile
1490+
test("C:\\foo\\bar\\gus")
1491+
.toFile();
1492+
14471493
// invalid
14481494
test(":\\foo")
14491495
.invalid();
@@ -2121,6 +2167,18 @@ static void doUnixTests() {
21212167
test("/foo/bar/gus/../..")
21222168
.normalize("/foo");
21232169

2170+
// equals
2171+
test("this")
2172+
.equals("this")
2173+
.notEquals(Path.of("that"))
2174+
.notEquals(null)
2175+
.notEquals(new Object())
2176+
.notEquals(Path.of("This"));
2177+
2178+
// toFile
2179+
test("/foo/bar/gus")
2180+
.toFile();
2181+
21242182
// invalid
21252183
test("foo\u0000bar")
21262184
.invalid();
@@ -2198,7 +2256,7 @@ public static void main(String[] args) {
21982256

21992257
// operating system specific
22002258
String osname = System.getProperty("os.name");
2201-
if (osname.startsWith("Windows")) {
2259+
if (Platform.isWindows()) {
22022260
doWindowsTests();
22032261
} else {
22042262
doUnixTests();

0 commit comments

Comments
 (0)