Adding unit tests for File.isAbsolute() method.

This commit is contained in:
Ben Limmer 2011-12-29 10:17:01 -07:00
parent a0c12ad259
commit d76191d2bb

29
test/Files.java Normal file
View File

@ -0,0 +1,29 @@
import java.io.File;
public class Files {
private static void expect(boolean v) {
if (! v) throw new RuntimeException();
}
private static void isAbsoluteTest(boolean absolutePath) {
File file = new File("test.txt");
if (absolutePath) {
file = file.getAbsoluteFile();
}
boolean isAbsolute = file.isAbsolute();
if (absolutePath) {
expect(isAbsolute);
} else {
expect(!isAbsolute);
}
}
public static void main(String[] args) {
isAbsoluteTest(true);
isAbsoluteTest(false);
}
}