Skip to content

Commit 1517d51

Browse files
committed
TestUtilsTest: add a test for createPath method
1 parent 78e0d50 commit 1517d51

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/test/java/org/scijava/test/TestUtilsTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
package org.scijava.test;
3333

34+
import static org.junit.Assert.assertEquals;
3435
import static org.junit.Assert.assertTrue;
3536

3637
import java.io.File;
@@ -80,4 +81,33 @@ public void sameDirectoryTwice() throws IOException {
8081
if (stream != null) stream.close();
8182
}
8283
}
84+
85+
/** Tests {@link TestUtils#createPath(File, String)}. */
86+
@Test
87+
public void testCreatePath() throws IOException {
88+
final File base = TestUtils.createTemporaryDirectory("create-path-");
89+
final String path = "/my/what/a/nested/directory/structure/you/have/gramma";
90+
File file = TestUtils.createPath(base, path);
91+
assertTrue(file.exists());
92+
assertEquals("gramma", file.getName());
93+
file = file.getParentFile();
94+
assertEquals("have", file.getName());
95+
file = file.getParentFile();
96+
assertEquals("you", file.getName());
97+
file = file.getParentFile();
98+
assertEquals("structure", file.getName());
99+
file = file.getParentFile();
100+
assertEquals("directory", file.getName());
101+
file = file.getParentFile();
102+
assertEquals("nested", file.getName());
103+
file = file.getParentFile();
104+
assertEquals("a", file.getName());
105+
file = file.getParentFile();
106+
assertEquals("what", file.getName());
107+
file = file.getParentFile();
108+
assertEquals("my", file.getName());
109+
file = file.getParentFile();
110+
assertEquals(base, file);
111+
}
112+
83113
}

0 commit comments

Comments
 (0)