1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
24
25
26
27 public class TestFloatCollections extends TestCase {
28
29
30
31 public TestFloatCollections(String testName) {
32 super(testName);
33 }
34
35 public static Test suite() {
36 return new TestSuite(TestFloatCollections.class);
37 }
38
39
40
41 public void testSingletonFloatListIterator() {
42 FloatListIterator iter = FloatCollections.singletonFloatListIterator((float)17);
43 assertTrue(!iter.hasPrevious());
44 assertTrue(iter.hasNext());
45 assertEquals(17,iter.next(),(float)0);
46 assertTrue(iter.hasPrevious());
47 assertTrue(!iter.hasNext());
48 assertEquals(17,iter.previous(),(float)0);
49 try {
50 iter.set((float)18);
51 fail("Expected UnsupportedOperationException");
52 } catch(UnsupportedOperationException e) {
53
54 }
55 }
56
57 public void testSingletonFloatIterator() {
58 FloatIterator iter = FloatCollections.singletonFloatIterator((float)17);
59 assertTrue(iter.hasNext());
60 assertEquals(17,iter.next(),(float)0);
61 assertTrue(!iter.hasNext());
62 try {
63 iter.remove();
64 fail("Expected UnsupportedOperationException");
65 } catch(UnsupportedOperationException e) {
66
67 }
68 }
69
70 public void testSingletonFloatList() {
71 FloatList list = FloatCollections.singletonFloatList((float)17);
72 assertEquals(1,list.size());
73 assertEquals(17,list.get(0),(float)0);
74 try {
75 list.add((float)18);
76 fail("Expected UnsupportedOperationException");
77 } catch(UnsupportedOperationException e) {
78
79 }
80 }
81
82 public void testUnmodifiableFloatListNull() {
83 try {
84 FloatCollections.unmodifiableFloatList(null);
85 fail("Expected NullPointerException");
86 } catch(NullPointerException e) {
87
88 }
89 }
90
91 public void testEmptyFloatList() {
92 assertSame(FloatCollections.EMPTY_FLOAT_LIST,FloatCollections.getEmptyFloatList());
93 assertTrue(FloatCollections.EMPTY_FLOAT_LIST.isEmpty());
94 try {
95 FloatCollections.EMPTY_FLOAT_LIST.add((float)1);
96 fail("Expected UnsupportedOperationExcpetion");
97 } catch(UnsupportedOperationException e) {
98
99 }
100 }
101
102 public void testUnmodifiableFloatIteratorNull() {
103 try {
104 FloatCollections.unmodifiableFloatIterator(null);
105 fail("Expected NullPointerException");
106 } catch(NullPointerException e) {
107
108 }
109 }
110
111 public void testEmptyFloatIterator() {
112 assertSame(FloatCollections.EMPTY_FLOAT_ITERATOR,FloatCollections.getEmptyFloatIterator());
113 assertTrue(! FloatCollections.EMPTY_FLOAT_ITERATOR.hasNext());
114 try {
115 FloatCollections.EMPTY_FLOAT_ITERATOR.remove();
116 fail("Expected UnsupportedOperationExcpetion");
117 } catch(UnsupportedOperationException e) {
118
119 }
120 }
121
122 public void testUnmodifiableFloatListIteratorNull() {
123 try {
124 FloatCollections.unmodifiableFloatListIterator(null);
125 fail("Expected NullPointerException");
126 } catch(NullPointerException e) {
127
128 }
129 }
130
131 public void testEmptyFloatListIterator() {
132 assertSame(FloatCollections.EMPTY_FLOAT_LIST_ITERATOR,FloatCollections.getEmptyFloatListIterator());
133 assertTrue(! FloatCollections.EMPTY_FLOAT_LIST_ITERATOR.hasNext());
134 assertTrue(! FloatCollections.EMPTY_FLOAT_LIST_ITERATOR.hasPrevious());
135 try {
136 FloatCollections.EMPTY_FLOAT_LIST_ITERATOR.add((float)1);
137 fail("Expected UnsupportedOperationExcpetion");
138 } catch(UnsupportedOperationException e) {
139
140 }
141 }
142 }
143