/*
* 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.checkedSet
* @author Josh Bloch
*/
public class CheckedSetBash {
int numItr = 100;
int setSize = 100;
for (int i=0; i<numItr; i++) {
fail("Set algebra identity 2 failed");
fail("Set algebra identity 3 failed");
fail("Set algebra identity 4 failed");
fail("Set algebra identity 5 failed");
fail("Set algebra identity 6 failed");
fail("Set algebra identity 7 failed");
fail("Set algebra identity 1 failed");
fail("Incorrect hashCode computation.");
while (e.hasNext())
fail("Couldn't remove element from copy.");
if (!intersection.isEmpty())
fail("Copy nonempty after deleting all elements.");
while (e.hasNext()) {
fail("Set doesn't contain one of its elements.");
e.remove();
fail("Set contains element after deletion.");
}
fail("Set nonempty after deleting all elements.");
fail("Set nonempty after clear.");
}
}
// Done inefficiently so as to exercise toArray
fail("Set not equal to copy.");
if (!s.containsAll(clone))
fail("Set does not contain copy.");
if (!clone.containsAll(s))
fail("Copy does not contain set.");
return clone;
}
if (!s.isEmpty())
fail("New instance non empty.");
return s;
}
for (int i=0; i<n; i++) {
boolean prePresent = s.contains(e);
if (!s.contains(e))
fail ("Element not present after addition.");
if (added == prePresent)
fail ("added == alreadyPresent");
fail ("Add returned true, but size didn't change.");
fail ("Add returned false, but size changed.");
}
}
throw new RuntimeException(s);
}
}