1 17 package org.apache.commons.collections.primitives; 18 19 import junit.framework.Test; 20 import junit.framework.TestCase; 21 import junit.framework.TestSuite; 22 23 27 public class TestRandomAccessFloatList extends TestCase { 28 29 32 public TestRandomAccessFloatList(String testName) { 33 super(testName); 34 } 35 36 public static Test suite() { 37 return new TestSuite(TestRandomAccessFloatList.class); 38 } 39 40 43 public void testAddIsUnsupportedByDefault() { 44 RandomAccessFloatList list = new AbstractRandomAccessFloatListImpl(); 45 try { 46 list.add((float)1); 47 fail("Expected UnsupportedOperationException"); 48 } catch(UnsupportedOperationException e) { 49 } 51 try { 52 list.set(0,(float)1); 53 fail("Expected UnsupportedOperationException"); 54 } catch(UnsupportedOperationException e) { 55 } 57 } 58 59 public void testAddAllIsUnsupportedByDefault() { 60 RandomAccessFloatList list = new AbstractRandomAccessFloatListImpl(); 61 FloatList list2 = new ArrayFloatList(); 62 list2.add((float)3); 63 try { 64 list.addAll(list2); 65 fail("Expected UnsupportedOperationException"); 66 } catch(UnsupportedOperationException e) { 67 } 69 } 70 71 public void testSetIsUnsupportedByDefault() { 72 RandomAccessFloatList list = new AbstractRandomAccessFloatListImpl(); 73 try { 74 list.set(0,(float)1); 75 fail("Expected UnsupportedOperationException"); 76 } catch(UnsupportedOperationException e) { 77 } 79 } 80 81 public void testRemoveElementIsUnsupportedByDefault() { 82 RandomAccessFloatList list = new AbstractRandomAccessFloatListImpl(); 83 try { 84 list.removeElementAt(0); 85 fail("Expected UnsupportedOperationException"); 86 } catch(UnsupportedOperationException e) { 87 } 89 } 90 91 94 95 static class AbstractRandomAccessFloatListImpl extends RandomAccessFloatList { 96 public AbstractRandomAccessFloatListImpl() { 97 } 98 99 102 public float get(int index) { 103 throw new IndexOutOfBoundsException (); 104 } 105 106 109 public int size() { 110 return 0; 111 } 112 113 } 114 } 115 | Popular Tags |