001: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
002:
003: This file is part of the db4o open source object database.
004:
005: db4o is free software; you can redistribute it and/or modify it under
006: the terms of version 2 of the GNU General Public License as published
007: by the Free Software Foundation and as clarified by db4objects' GPL
008: interpretation policy, available at
009: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011: Suite 350, San Mateo, CA 94403, USA.
012:
013: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014: WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: for more details.
017:
018: You should have received a copy of the GNU General Public License along
019: with this program; if not, write to the Free Software Foundation, Inc.,
020: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
021: package com.db4o.db4ounit.jre5.collections;
022:
023: import java.util.*;
024:
025: import com.db4o.collections.*;
026:
027: import db4ounit.*;
028:
029: public class ArrayList4TestCase implements TestLifeCycle {
030:
031: public static void main(String[] args) {
032: new TestRunner(ArrayList4TestCase.class).run();
033: }
034:
035: public ArrayList4<Integer> _list;
036:
037: public void setUp() throws Exception {
038: _list = new ArrayList4<Integer>();
039: ArrayList4Asserter.createList(_list);
040: }
041:
042: public void tearDown() throws Exception {
043:
044: }
045:
046: public void testConstructor() throws Exception {
047: ArrayList4<Integer> arrayList = new ArrayList4<Integer>();
048: fill(arrayList);
049: Assert.areEqual(ArrayList4Asserter.CAPACITY, arrayList.size());
050: }
051:
052: public void testConstructor_I_LegalArguments1() throws Exception {
053: ArrayList4<Integer> arrayList;
054: arrayList = new ArrayList4<Integer>(ArrayList4Asserter.CAPACITY);
055: fill(arrayList);
056: Assert.areEqual(ArrayList4Asserter.CAPACITY, arrayList.size());
057: }
058:
059: public void testConstructor_I_LegalArguments2() throws Exception {
060: ArrayList4<Integer> arrayList;
061: arrayList = new ArrayList4<Integer>(0);
062: fill(arrayList);
063: Assert.areEqual(ArrayList4Asserter.CAPACITY, arrayList.size());
064: }
065:
066: public void testConstructor_I_IllegalArgumentException()
067: throws Exception {
068: Assert.expect(IllegalArgumentException.class, new CodeBlock() {
069: public void run() throws Throwable {
070: new ArrayList4<Integer>(-1);
071: }
072: });
073: }
074:
075: public void testConstructor_LCollection_NullPointerException()
076: throws Exception {
077: Assert.expect(NullPointerException.class, new CodeBlock() {
078: public void run() throws Throwable {
079: new ArrayList4<Integer>(null);
080: }
081: });
082: }
083:
084: public void testConstructor_LCollection() throws Exception {
085: ArrayList4<Integer> arrayList = new ArrayList4<Integer>(_list);
086: Assert.areEqual(_list.size(), arrayList.size());
087: Assert.isTrue(Arrays.equals(_list.toArray(), arrayList
088: .toArray()));
089:
090: }
091:
092: private void fill(ArrayList4<Integer> arrayList) {
093: for (int i = 0; i < ArrayList4Asserter.CAPACITY; i++) {
094: arrayList.add(new Integer(i));
095: }
096: }
097:
098: public void testAdd() throws Exception {
099: ArrayList4Asserter.assertAdd(_list);
100: }
101:
102: public void testAdd_LObject() throws Exception {
103: ArrayList4Asserter.assertAdd_LObject(_list);
104: }
105:
106: public void testAddAll_LCollection() throws Exception {
107: ArrayList4Asserter.assertAddAll_LCollection(_list);
108: }
109:
110: public void testClear() throws Exception {
111: ArrayList4Asserter.assertClear(_list);
112: }
113:
114: public void testContains() throws Exception {
115: ArrayList4Asserter.assertContains(_list);
116: }
117:
118: public void testContainsAll() throws Exception {
119: ArrayList4Asserter.assertContainsAll(_list);
120: }
121:
122: public void testIndexOf() throws Exception {
123: ArrayList4Asserter.assertIndexOf(_list);
124: }
125:
126: public void testIsEmpty() throws Exception {
127: ArrayList4Asserter.assertIsEmpty(_list);
128: }
129:
130: public void testIterator() throws Exception {
131: ArrayList4Asserter.assertIterator(_list);
132: }
133:
134: public void testLastIndexOf() throws Exception {
135: ArrayList4Asserter.assertLastIndexOf(_list);
136: }
137:
138: public void testRemove_LObject() throws Exception {
139: ArrayList4Asserter.assertRemove_LObject(_list);
140: }
141:
142: public void testRemoveAll() throws Exception {
143: ArrayList4Asserter.assertRemoveAll(_list);
144: }
145:
146: public void testSet() throws Exception {
147: ArrayList4Asserter.assertSet(_list);
148: }
149:
150: public void testSize() throws Exception {
151: ArrayList4Asserter.assertSize(_list);
152: }
153:
154: public void testToArray() throws Exception {
155: ArrayList4Asserter.assertToArray(_list);
156: }
157:
158: public void testToArray_LObject() throws Exception {
159: ArrayList4Asserter.assertToArray_LObject(_list);
160: }
161:
162: public void testToString() throws Exception {
163: ArrayList4Asserter.assertToString(_list);
164: }
165:
166: public void testTrimToSize_EnsureCapacity() throws Exception {
167: ArrayList4Asserter.assertTrimToSize_EnsureCapacity(_list);
168: }
169:
170: public void testTrimToSize_Remove() throws Exception {
171: ArrayList4Asserter.assertTrimToSize_Remove(_list);
172: }
173:
174: public void testTrimToSize_Iterator() throws Exception {
175: ArrayList4Asserter.assertTrimToSize_Iterator(_list);
176: }
177:
178: public void testEnsureCapacity_Iterator() throws Exception {
179: ArrayList4Asserter.assertEnsureCapacity_Iterator(_list);
180: }
181:
182: public void testClear_Iterator() throws Exception {
183: ArrayList4Asserter.assertClear_Iterator(_list);
184: }
185:
186: public void testClone() throws Exception {
187: ArrayList4Asserter.assertClone(_list);
188: }
189:
190: public void testEquals() throws Exception {
191: ArrayList4Asserter.assertEquals(_list);
192: }
193:
194: public void testIteratorNext_NoSuchElementException()
195: throws Exception {
196: ArrayList4Asserter
197: .assertIteratorNext_NoSuchElementException(_list);
198: }
199:
200: public void testIteratorNext_ConcurrentModificationException()
201: throws Exception {
202: ArrayList4Asserter
203: .assertIteratorNext_ConcurrentModificationException(_list);
204: }
205:
206: public void testIteratorNext() throws Exception {
207: ArrayList4Asserter.assertIteratorNext(_list);
208: }
209:
210: public void testIteratorRemove() throws Exception {
211: ArrayList4Asserter.assertIteratorRemove(_list);
212: }
213:
214: public void testRemove_IllegalStateException() throws Exception {
215: ArrayList4Asserter.assertRemove_IllegalStateException(_list);
216: }
217:
218: public void testIteratorRemove_ConcurrentModificationException()
219: throws Exception {
220: ArrayList4Asserter
221: .assertIteratorRemove_ConcurrentModificationException(_list);
222: }
223:
224: public void testSubList() throws Exception {
225: ArrayList4Asserter.assertSubList(_list);
226: }
227:
228: public void testSubList_ConcurrentModification() throws Exception {
229: ArrayList4Asserter.assertSubList_ConcurrentModification(_list);
230: }
231:
232: public void testSubList_Clear() throws Exception {
233: ArrayList4Asserter.assertSubList_Clear(_list);
234: }
235:
236: public void testSubList_Clear2() throws Exception {
237: ArrayList4Asserter.assertSubList_Clear2(_list);
238: }
239:
240: }
|