1 19 20 package org.netbeans.lib.editor.util; 21 22 import java.util.Arrays ; 23 import java.util.List ; 24 import org.netbeans.junit.NbTestCase; 25 26 public class ArrayUtilitiesTest extends NbTestCase { 27 28 public ArrayUtilitiesTest(String testName) { 29 super(testName); 30 } 31 32 public void testUnmodifiableList() throws Exception { 33 String [] arr = new String [] { "haf", "cau", "test" }; 34 List <String > l = ArrayUtilities.unmodifiableList(arr); 35 assertEquals("haf", l.get(0)); 36 assertEquals("cau", l.get(1)); 37 assertEquals("test", l.get(2)); 38 try { 39 l.add("no"); 40 fail("Modifiable!"); 41 } catch (UnsupportedOperationException e) { 42 } 44 assertEquals(3, l.size()); 45 Object a[] = l.toArray(); 46 assertTrue(Arrays.equals(arr, a)); 47 a = l.toArray(new String [2]); 48 assertTrue(Arrays.equals(arr, a)); 49 50 } 51 52 } 53 | Popular Tags |