Forráskód Böngészése

test
ListUtils#constCopy(T[])

Ranides Atterwim 13 éve
szülő
commit
6976e1b0c7

+ 8 - 0
src/main/java/net/ranides/assira/collection/ListUtils.java

@@ -302,6 +302,10 @@ public final class ListUtils {
         return list;
     }
     
+    public static <T> List<T> constCopy(T[] values) {
+        return constCopy(Arrays.asList(values));
+    }
+    
     public static <T> List<T> constCopy(Collection<? extends T> values) {
         return new ConstList<T>(values);
     }
@@ -309,6 +313,10 @@ public final class ListUtils {
     public static class ConstList<T> extends AbstractList<T> {
 
         private final Object[] array;
+        
+        public ConstList(T[] values) {
+            this.array = ArrayUtils.arraycopy(values);
+        }
 
         public ConstList(Collection<? extends T> values) {
             this.array = values.toArray();

+ 13 - 0
src/test/java/net/ranides/assira/io/PathHelperTest.java

@@ -6,6 +6,7 @@
  */
 package net.ranides.assira.io;
 
+import net.ranides.assira.trace.LoggerUtils;
 import org.junit.Test;
 import static org.junit.Assert.*;
 
@@ -19,9 +20,21 @@ public class PathHelperTest {
     public PathHelperTest() {
     }
     
+    @Test
+    public void testExtension() throws PathConvertException {
+        assertEquals(".txt", PathHelper.getExtension("file.txt"));
+        assertEquals(".txt", PathHelper.getExtension("\\base\\file.txt"));
+        assertEquals(".txt", PathHelper.getExtension("/base/file.txt"));
+        assertEquals(".txt", PathHelper.getExtension("/base/file.log.txt"));
+    }
+    
+    
     @Test
     public void testRelative() throws PathConvertException {
         
+        assertEquals("..\\..\\temp", PathHelper.asRelative("base/home/system/drivers", "base/home/temp"));
+
+        
         assertEquals("..\\..\\temp", PathHelper.asRelative("base\\home\\system\\drivers", "base\\home\\temp"));
         
         assertEquals("..\\..\\temp\\data\\int\\value", PathHelper.asRelative("base\\home\\system\\drivers", "base\\home\\temp\\data\\int\\value"));