You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/06/01 19:35:42 UTC
svn commit: r780742 - in
/incubator/pivot/trunk/core/test/pivot/collections/test: ArrayListTest.java
EnumListTest.java LinkedListTest.java
Author: gbrown
Date: Mon Jun 1 17:35:42 2009
New Revision: 780742
URL: http://svn.apache.org/viewvc?rev=780742&view=rev
Log:
Restore more inadvertently deleted files.
Added:
incubator/pivot/trunk/core/test/pivot/collections/test/EnumListTest.java
incubator/pivot/trunk/core/test/pivot/collections/test/LinkedListTest.java
Modified:
incubator/pivot/trunk/core/test/pivot/collections/test/ArrayListTest.java
Modified: incubator/pivot/trunk/core/test/pivot/collections/test/ArrayListTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/test/pivot/collections/test/ArrayListTest.java?rev=780742&r1=780741&r2=780742&view=diff
==============================================================================
--- incubator/pivot/trunk/core/test/pivot/collections/test/ArrayListTest.java (original)
+++ incubator/pivot/trunk/core/test/pivot/collections/test/ArrayListTest.java Mon Jun 1 17:35:42 2009
@@ -16,6 +16,42 @@
*/
package pivot.collections.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import pivot.collections.ArrayList;
+import pivot.collections.Sequence;
+
public class ArrayListTest {
- // TODO
+ @Test
+ public void basicTest() {
+ ArrayList<String> list = new ArrayList<String>();
+ list.insert("B", 0);
+ list.insert("C", 1);
+ list.insert("D", 2);
+ list.insert("A", 0);
+
+ assertEquals(ArrayList.binarySearch(list, "A"), 0);
+
+ list.remove(0, 1);
+ assertEquals(list.get(0), "B");
+ assertEquals(list.getLength(), 3);
+ assertEquals(list.indexOf("C"), 1);
+
+ Sequence<String> removed = list.remove(1, 1);
+ assertNotNull(removed.get(0));
+ assertTrue(removed.get(0).equals("C"));
+
+ list.trimToSize();
+ list.ensureCapacity(10);
+ assertEquals(list.getCapacity(), 10);
+
+ list.insert("E", 1);
+ assertEquals(list.getLength(), 3);
+ assertNotNull(list.get(1));
+ assertTrue(list.get(1).equals("E"));
+ }
}
Added: incubator/pivot/trunk/core/test/pivot/collections/test/EnumListTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/test/pivot/collections/test/EnumListTest.java?rev=780742&view=auto
==============================================================================
--- incubator/pivot/trunk/core/test/pivot/collections/test/EnumListTest.java (added)
+++ incubator/pivot/trunk/core/test/pivot/collections/test/EnumListTest.java Mon Jun 1 17:35:42 2009
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.collections.test;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import pivot.collections.EnumList;
+
+public class EnumListTest {
+ public enum TestEnum {
+ A,
+ B,
+ C
+ }
+
+ @Test
+ public void basicTest() {
+ EnumList<TestEnum> enumList = new EnumList<TestEnum>(TestEnum.class);
+
+ assertEquals(enumList.get(0), TestEnum.A);
+ assertEquals(enumList.get(1), TestEnum.B);
+ assertEquals(enumList.getLength(), 3);
+ }
+}
Added: incubator/pivot/trunk/core/test/pivot/collections/test/LinkedListTest.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/core/test/pivot/collections/test/LinkedListTest.java?rev=780742&view=auto
==============================================================================
--- incubator/pivot/trunk/core/test/pivot/collections/test/LinkedListTest.java (added)
+++ incubator/pivot/trunk/core/test/pivot/collections/test/LinkedListTest.java Mon Jun 1 17:35:42 2009
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package pivot.collections.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import pivot.collections.LinkedList;
+import pivot.collections.Sequence;
+import pivot.serialization.JSONSerializer;
+
+public class LinkedListTest {
+ @Test
+ public void basicTest() {
+ LinkedList<String> list = new LinkedList<String>();
+ list.insert("B", 0);
+ list.insert("C", 1);
+ list.insert("D", 2);
+ list.insert("A", 0);
+
+ assertEquals(list.indexOf("A"), 0);
+
+ list.remove(0, 1);
+ assertEquals(list.get(0), "B");
+ assertEquals(list.getLength(), 3);
+ assertEquals(list.indexOf("C"), 1);
+
+ Sequence<String> removed = list.remove(1, 1);
+ assertNotNull(removed.get(0));
+ assertTrue(removed.get(0).equals("C"));
+
+ list.insert("E", 1);
+ assertEquals(list.getLength(), 3);
+ assertNotNull(list.get(1));
+ assertTrue(list.get(1).equals("E"));
+
+ list.update(1, "F");
+ assertNotNull(list.get(1));
+ assertTrue(list.get(1).equals("F"));
+
+ list.insert("G", 0);
+ assertEquals(JSONSerializer.toString(list), "[\"G\", \"B\", \"F\", \"D\"]");
+ }
+}