Skip to content

Commit 716deee

Browse files
committed
Added FloatList test
1 parent a44236c commit 716deee

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

core/test/processing/data/FloatListTest.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,50 @@ public void testPop(){
132132
assertEquals(6.0F, testList.pop(), 0.0F);
133133
assertEquals(0, testList.size());
134134
}
135+
136+
@Test
137+
public void testRemove(){
138+
FloatList testList = new FloatList(new float[]{1.0F, 2.0F, 3.0F });
139+
140+
float removed = testList.remove(1);
141+
assertEquals(2.0F, removed, 0.0F);
142+
assertEquals(2, testList.size());
143+
assertEquals(1.0F, testList.get(0), 0.0F);
144+
assertEquals(3.0F, testList.get(1), 0.0F);
145+
}
146+
147+
@Test
148+
public void testRemoveValues(){
149+
FloatList testList = new FloatList(new float[]{1.0F, 2.0F, 2.0F, 3.0F, 2.0F});
150+
151+
int removed = testList.removeValues(2.0F);
152+
assertEquals(3, removed);
153+
assertEquals(2, testList.size());
154+
assertEquals(1.0F, testList.get(0), 0.0F);
155+
assertEquals(3.0F, testList.get(1), 0.0F);
156+
}
157+
@Test
158+
public void testReplaceValue() {
159+
FloatList testList = new FloatList(new float[]{1.0F, 2.0F, 2.0F, 3.0F});
160+
161+
boolean changed = testList.replaceValue(2.0F, 99.0F);
162+
assertTrue(changed);
163+
assertEquals(99.0F, testList.get(1), 0.0F);
164+
assertEquals(2.0F, testList.get(2), 0.0F);
165+
}
166+
@Test
167+
public void testReplaceValueNotFound() {
168+
FloatList testList = new FloatList(new float[]{1.0F, 2.0F});
169+
170+
boolean changed = testList.replaceValue(5.0F, 99.0F);
171+
assertFalse(changed);
172+
}
173+
@Test
174+
public void testAdd() {
175+
FloatList testList = new FloatList(new float[]{10.0F, 20.0F});
176+
177+
testList.add(0, 5.0F);
178+
assertEquals(15.0F, testList.get(0), 0.0F);
179+
assertEquals(20.0F, testList.get(1), 0.0F);
180+
}
135181
}

0 commit comments

Comments
 (0)