### Question:
SizeFileComparator extends AbstractFileComparator implements Serializable { public int compare(final File file1, final File file2) { long size1 = 0; if (file1.isDirectory()) { size1 = sumDirectoryContents && file1.exists() ? FileUtils.sizeOfDirectory(file1) : 0; } else { size1 = file1.length(); } long size2 = 0; if (file2.isDirectory()) { size2 = sumDirectoryContents && file2.exists() ? FileUtils.sizeOfDirectory(file2) : 0; } else { size2 = file2.length(); } final long result = size1 - size2; if (result < 0) { return -1; } else if (result > 0) { return 1; } else { return 0; } } SizeFileComparator();  SizeFileComparator(final boolean sumDirectoryContents); int compare(final File file1, final File file2); @Override String toString(); static final Comparator<File> SIZE_COMPARATOR; static final Comparator<File> SIZE_REVERSE; static final Comparator<File> SIZE_SUMDIR_COMPARATOR; static final Comparator<File> SIZE_SUMDIR_REVERSE; }### Answer:
@Test public void testNonexistantFile() { final File nonexistantFile = new File(new File("."), "nonexistant.txt"); assertFalse(nonexistantFile.exists()); assertTrue("less", comparator.compare(nonexistantFile, moreFile) < 0); }
@Test public void testCompareDirectorySizes() { assertEquals("sumDirectoryContents=false", 0, comparator.compare(smallerDir, largerDir)); assertEquals("less", -1, SizeFileComparator.SIZE_SUMDIR_COMPARATOR.compare(smallerDir, largerDir)); assertEquals("less", 1, SizeFileComparator.SIZE_SUMDIR_REVERSE.compare(smallerDir, largerDir)); }