CheckedMapBash.java revision 2362
/*
* 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 5023830
* @summary Unit test for Collections.checkedMap
* @author Josh Bloch
*/
public class CheckedMapBash {
int numItr = 100;
int mapSize = 100;
// Linked List test
for (int i=0; i<numItr; i++) {
for (int j=0; j<mapSize; j++) {
do {
} while (m.containsKey(newHead));
}
fail("Size not as expected.");
{
fail("Incorrect hashCode computation.");
fail("Incorrect equals computation.");
}
fail("Collection views test failed.");
int j=0;
if (!m.containsKey(head))
fail("Linked list doesn't contain a link.");
fail("Could not retrieve a link.");
j++;
}
if (!m.isEmpty())
fail("Map nonempty after removing all links.");
if (j != mapSize)
fail("Linked list size not as expected.");
}
for (int i=0; i<mapSize; i++)
fail("put returns a non-null value erroenously.");
fail("contains value "+i);
fail("put returns a null value erroenously.");
fail("Clone not equal to original. (1)");
fail("Clone not equal to original. (2)");
fail("Clone not equal to original. (3)");
fail("Clone not equal to original. (4)");
if (!s.containsAll(s2))
fail("Original doesn't contain clone!");
if (!s2.containsAll(s))
fail("Clone doesn't contain original!");
fail("entrySet().removeAll failed.");
fail("clear failed.");
while(i.hasNext()) {
i.next();
i.remove();
}
if (!m.isEmpty())
fail("Iterator.remove() failed");
}
if (!m.isEmpty())
fail("New instance non empty.");
return m;
}
throw new RuntimeException(s);
}
}