/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4904067
* @summary Unit test for Collections.checkedList
* @author Josh Bloch
*/
public class CheckedListBash {
int numItr = 100;
int listSize = 100;
for (int i=0; i<numItr; i++) {
fail("List algebra identity 2 failed");
fail("List algebra identity 3 failed");
fail("List algebra identity 4 failed");
fail("List algebra identity 5 failed");
fail("List algebra identity 6 failed");
fail("List algebra identity 7 failed");
fail("List algebra identity 1 failed");
while (e.hasNext())
if (!intersection.isEmpty())
fail("Copy nonempty after deleting all elements.");
while (e.hasNext()) {
fail("List doesn't contain one of its elements.");
e.remove();
}
fail("List nonempty after deleting all elements.");
fail("Clear didn't reduce size to zero.");
fail("addAll(int, Collection) doesn't work.");
// Reverse List
// Reverse it again
fail("set(int, Object) doesn't work");
}
for (int i=0; i<listSize; i++)
fail("Size of [0..n-1] != n");
fail("Failed to remove all odd nubmers.");
fail("Failed to remove all even nubmers.");
fail("Failed to reconstruct ints from odds and evens.");
while (itEven.hasPrevious()) {
}
}
fail("Iterator.set failed to change value.");
fail("Failed to reconstruct ints with ListIterator.");
int i=0;
fail("Apparent duplicate detected.");
fail("subList/lastIndexOf is screwy.");
i++;
}
AddRandoms(l, listSize);
fail("toArray(Object[]) is hosed (1)");
fail("toArray(Object[]) is hosed (2)");
fail("toArray(Object[]) is hosed (3)");
}
// Done inefficiently so as to exercise toArray
fail("Incorrect hashCode computation.");
fail("List not equal to copy.");
if (!s.containsAll(clone))
fail("List does not contain copy.");
if (!clone.containsAll(s))
fail("Copy does not contain list.");
return clone;
}
if (!s.isEmpty())
fail("New instance non empty.");
return s;
}
for (int i=0; i<n; i++) {
if (!s.add(e))
fail ("Add failed.");
fail ("Add didn't increase size by 1.");
}
}
throw new RuntimeException(s);
}
}