commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r721741 - /commons/proper/io/trunk/src/test/org/apache/commons/io/comparator/ComparatorAbstractTestCase.java
Date Sat, 29 Nov 2008 23:38:46 GMT
Author: niallp
Date: Sat Nov 29 15:38:46 2008
New Revision: 721741

URL: http://svn.apache.org/viewvc?rev=721741&view=rev
Log:
Comparator test improvements

Modified:
    commons/proper/io/trunk/src/test/org/apache/commons/io/comparator/ComparatorAbstractTestCase.java

Modified: commons/proper/io/trunk/src/test/org/apache/commons/io/comparator/ComparatorAbstractTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/org/apache/commons/io/comparator/ComparatorAbstractTestCase.java?rev=721741&r1=721740&r2=721741&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/org/apache/commons/io/comparator/ComparatorAbstractTestCase.java
(original)
+++ commons/proper/io/trunk/src/test/org/apache/commons/io/comparator/ComparatorAbstractTestCase.java
Sat Nov 29 15:38:46 2008
@@ -21,6 +21,7 @@
 import java.util.Comparator;
 import java.util.List;
 
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.testtools.FileBasedTestCase;
 
 /**
@@ -68,6 +69,7 @@
         equalFile2 = null;
         lessFile = null;
         moreFile = null;
+        FileUtils.deleteDirectory(getTestDirectory());
     }
 
     /**
@@ -89,14 +91,21 @@
     }
 
     /**
+     * Test comparator array sort is null safe.
+     */
+    public void testSortArrayNull() {
+        assertNull(comparator.sort((File[])null));
+    }
+
+    /**
      * Test the comparator array sort.
      */
     public void testSortArray() {
-    	File[] files = new File[3];
-    	files[0] = equalFile1;
-    	files[1] = moreFile;
-    	files[2] = lessFile;
-    	comparator.sort(files);
+        File[] files = new File[3];
+        files[0] = equalFile1;
+        files[1] = moreFile;
+        files[2] = lessFile;
+        comparator.sort(files);
         assertTrue("equal", files[0] == lessFile);
         assertTrue("less",  files[1] == equalFile1);
         assertTrue("more",  files[2] == moreFile);
@@ -106,13 +115,28 @@
      * Test the comparator array sort.
      */
     public void testSortList() {
-    	List<File> files = new ArrayList<File>();
-    	files.add(equalFile1);
-    	files.add(moreFile);
-    	files.add(lessFile);
-    	comparator.sort(files);
+        List<File> files = new ArrayList<File>();
+        files.add(equalFile1);
+        files.add(moreFile);
+        files.add(lessFile);
+        comparator.sort(files);
         assertTrue("equal", files.get(0) == lessFile);
         assertTrue("less",  files.get(1) == equalFile1);
         assertTrue("more",  files.get(2) == moreFile);
     }
+
+    /**
+     * Test comparator list sort is null safe.
+     */
+    public void testSortListNull() {
+        assertNull(comparator.sort((List)null));
+    }
+
+    /**
+     * Test comparator toString.
+     */
+    public void testToString() {
+        assertNotNull("comparator", comparator.toString());
+        assertTrue("reverse", reverse.toString().startsWith("ReverseComparator["));
+    }
 }



Mime
View raw message