@Test(groups = "Functional", dataProvider = "dirnamesAndBasenames")
public void testDirnamesAndBasenames(String filename, int where,
- String dirname, String basename)
+ String dirname, String basename, String notInDirname)
{
File file = new File(filename);
String d = FileUtils.getDirname(file);
else if (where > 0)
Assert.assertTrue(d.endsWith(dirname), "getDirname(" + file.getPath()
+ ")=" + d + " didn't end with '" + d + "'");
+
+ // ensure dirname doesn't end with basename (which means you can't use same
+ // filename as dir in tests!)
+ Assert.assertFalse(d.endsWith(b));
+
+ if (notInDirname != null)
+ Assert.assertFalse(d.contains(notInDirname));
}
@DataProvider(name = "patternsAndMinNumFiles")
public Object[][] dirnamesAndBasenames()
{
return new Object[][] { // -1=startsWith, 0=equals, 1=endsWith
- { "~/hello/sailor", -1, System.getProperty("user.home"), "sailor" }, //
- { "~/hello/sailor", 1, "/hello", "sailor" }, //
- { "./examples/uniref50.fa", -1, "/", "uniref50" }, //
- { "./examples/uniref50.fa", 1, "/examples", "uniref50" }, //
- { "examples/uniref50.fa", 1, "/examples", "uniref50" }, //
+ { "~/hello/sailor", -1, System.getProperty("user.home"), "sailor",
+ "~" }, //
+ { "~/hello/sailor", 1, "/hello", "sailor", "~" }, //
+ { "./examples/uniref50.fa", -1, "/", "uniref50", null }, //
+ { "./examples/uniref50.fa", 1, "/examples", "uniref50", null }, //
+ { "examples/uniref50.fa", 1, "/examples", "uniref50", null }, //
};
}
}