Commit c7ad7f34 authored by Dr. Martin Goik's avatar Dr. Martin Goik

single file name char test, simplified »if«

parent 077ce169
......@@ -56,11 +56,7 @@ public class FileMetaInfo {
}
} else {
drive = NO_DRIVE;
if (filePathName.charAt(0) == fileSeparatorChar) {
isRelative = false;
} else {
isRelative = true;
}
isRelative = filePathName.charAt(0) != fileSeparatorChar;
pathComponents = new StringTokenizer(filePathName, fileSeparatorString);
}
// Now we must scan for directory separators (either '/' on UNIX or '\' on Windows)
......
......@@ -52,16 +52,29 @@ public class MetaInfoUnixTest {
Assert.assertEquals(null, fmi.extension);
}
@Test
public void testRelativeWithExtension() {
Assume.assumeFalse(isWindows);
final FileMetaInfo fmi = new FileMetaInfo("../../Desktop/icon.gif");
Assert.assertTrue(fmi.isRelative);
Assert.assertEquals(FileMetaInfo.NO_DRIVE, fmi.drive);
Assert.assertEquals("../../Desktop", fmi.path);
Assert.assertEquals("icon", fmi.basename);
Assert.assertEquals("gif", fmi.extension);
}
@Test
public void testRelativeWithExtension() {
Assume.assumeFalse(isWindows);
final FileMetaInfo fmi = new FileMetaInfo("../../Desktop/icon.gif");
Assert.assertTrue(fmi.isRelative);
Assert.assertEquals(FileMetaInfo.NO_DRIVE, fmi.drive);
Assert.assertEquals("../../Desktop", fmi.path);
Assert.assertEquals("icon", fmi.basename);
Assert.assertEquals("gif", fmi.extension);
}
@Test
public void testRelativeSingleChar() {
Assume.assumeFalse(isWindows);
final FileMetaInfo fmi = new FileMetaInfo("a");
Assert.assertTrue(fmi.isRelative);
Assert.assertEquals(FileMetaInfo.NO_DRIVE, fmi.drive);
Assert.assertEquals("", fmi.path);
Assert.assertEquals("a", fmi.basename);
Assert.assertEquals(null, fmi.extension);
}
}
......@@ -64,4 +64,17 @@ public class MetaInfoWindowsTest {
Assert.assertEquals("icon", fmi.basename);
Assert.assertEquals("gif", fmi.extension);
}
@Test
public void testRelativeSingleChar() {
Assume.assumeTrue(isWindows);
final FileMetaInfo fmi = new FileMetaInfo("a");
Assert.assertTrue(fmi.isRelative);
Assert.assertEquals(FileMetaInfo.NO_DRIVE, fmi.drive);
Assert.assertEquals("", fmi.path);
Assert.assertEquals("a", fmi.basename);
Assert.assertEquals(null, fmi.extension);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment