Instructions
Objective
Write a java assignment program to use a dictionary, maps, and hash table.
Requirements and Specifications
Source Code
TEST DICTIONARY
import java.util.Collection;
import java.util.Iterator;
import java.util.function.Supplier;
import junit.framework.TestCase;
import edu.uwm.cs351.ps.Dictionary;
import edu.uwm.cs351.ps.ExecutionException;
import edu.uwm.cs351.ps.Name;
public class TestDictionary extends TestCase {
protected void assertException(Class c, Runnable r) {
try {
r.run();
assertFalse("Exception should have been thrown",true);
} catch (RuntimeException ex) {
assertTrue("should throw exception of " + c + ", not of " + ex.getClass(), c.isInstance(ex));
}
}
private Dictionary dict;
@Override
protected void setUp() {
try {
assert dict.size() > 0 : "something terribly wrong";
assertFalse("Need to add '-ea' to VM Arguments on Arguments Pane of Run Configuration",true);
} catch (NullPointerException ex) {
assertTrue("assertions set correctly",true);
}
dict = new Dictionary();
}
protected Name n(String s) {
return new Name(s);
}
protected String eval(Supplier r) {
try {
return ""+r.get();
} catch (RuntimeException e) {
return e.getClass().getSimpleName();
}
}
public void test00() {
assertEquals(0,dict.size());
}
public void test01() {
assertException(ExecutionException.class,() -> { dict.get(n("foo")); });
}
public void test02() {
assertFalse(dict.known(n("bar")));
}
public void test03() {
assertFalse(dict.known(null));
}
public void test04() {
assertException(ExecutionException.class,() -> dict.get(null));
}
public void test05() {
assertException(ExecutionException.class, () -> { dict.put(null,"hello"); });
}
public void test10() {
dict.put(n("hello"),8);
assertEquals(1,dict.size());
}
public void test11() {
dict.put(n("bye"),9);
assertEquals(Integer.valueOf(9),dict.get(n("bye")));
assertException(ExecutionException.class,() -> dict.get(n("hello")));
}
public void test12() {
dict.put(n("time"), 10.30);
assertTrue(dict.known(n("time")));
assertFalse(dict.known(n("10.30")));
}
public void test13() {
dict.put(n("hello"),null);
assertNull(dict.get(n("hello")));
dict.put(n("hello"),"bye");
assertEquals("bye",dict.get(n("hello")));
}
public void test14() {
dict.put(n("apples"),15);
assertFalse(dict.known(n("bacon")));
}
public void test15() {
dict.put(n("CS351"), 3);
assertException(ExecutionException.class,() -> dict.get(n("CS251")));
}
public void test16() {
dict.put(n("hello"),null);
assertNull(dict.get(n("hello")));
assertTrue(dict.known(n("hello")));
}
public void test17() {
dict.put(n("WI"),"Madison");
assertException(ExecutionException.class,() -> dict.get(n("Wi")));
}
public void test18() {
dict.put(n("VA"),"Richmond");
assertFalse(dict.known(null));
}
public void test19() {
dict.put(n("OK"),"Oklahoma City");
assertException(ExecutionException.class,() -> dict.get(null));
}
public void test20() {
dict.put(n("WI"),"Madison");
dict.put(n("IL"),"Springfield");
assertEquals(2,dict.size());
assertEquals("Madison",dict.get(n("WI")));
assertEquals("Springfield",dict.get(n("IL")));
}
public void test21() {
dict.put(n("CA"),"Sacramento");
dict.put(n("NV"),"Carson City");
assertEquals("Carson City",dict.get(n("NV")));
}
public void test22() {
dict.put(n("IL"),"Springfield");
dict.put(n("WI"), "Madison");
assertTrue(dict.known(n("WI")));
assertFalse(dict.known(n("CA")));
}
public void test23() {
dict.put(n("TX"),"Austin");
dict.put(n("FL"),"Tallahassee");
assertException(ExecutionException.class, () -> dict.get(n("WI")));
}
public void test24() {
dict.put(n("MN"),"Saint Paul");
dict.put(n("MT"),"Helena");
assertException(ExecutionException.class, () -> dict.get(n("CA")));
assertException(ExecutionException.class, () -> dict.get(n("MO")));
}
public void test25() {
dict.put(n("ND"),"Bismarck");
dict.put(n("SD"),"Pierre");
assertEquals("Pierre",dict.get(n("SD")));
dict.put(n("SD"),"Sioux Falls");
assertEquals("Sioux Falls",dict.get(n("SD")));
}
public void test26() {
dict.put(n("MI"),"Lansing");
dict.put(n("OH"),"Dayton");
dict.put(n("OH"),"Columbus");
assertEquals(2,dict.size());
}
public void test27() {
dict.put(n("IN"),"Indianapolis");
dict.put(n("OH"),"Columbus");
dict.put(n("IN"),"Gary");
assertEquals("Gary",dict.get(n("IN")));
assertTrue(dict.known(n("OH")));
assertEquals(2,dict.size());
}
public void test28() {
dict.put(n("IL"),"Springfield");
dict.put(n("WI"),"Madison");
dict.put(n("IL"),"Chicago");
dict.put(n("WI"),"Milwaukee");
dict.put(n("WI"),"Madison");
dict.put(n("IL"),"Springfield");
assertEquals(2,dict.size());
assertEquals("Madison",dict.get(n("WI")));
}
public void test29() {
dict.put(n("NM"),"Santa Fe");
dict.put(n("NC"),"Raleigh");
assertException(ExecutionException.class,() -> { dict.put(null,"London"); });
}
public void test30() {
dict.put(n("AR"),"Little Rock");
dict.put(n("CO"),"Denver");
dict.put(n("PA"),"Harrisburg");
assertEquals(3,dict.size());
assertTrue(dict.known(n("PA")));
assertTrue(dict.known(n("AR")));
assertTrue(dict.known(n("CO")));
assertFalse(dict.known(n("AK")));
assertFalse(dict.known(n("AZ")));
assertFalse(dict.known(n("MS")));
assertFalse(dict.known(n("TX")));
assertEquals("Harrisburg",dict.get(n("PA")));
assertEquals("Denver",dict.get(n("CO")));
assertEquals("Little Rock",dict.get(n("AR")));
assertException(ExecutionException.class, () -> dict.get(n("AL")));
assertException(ExecutionException.class, () -> dict.get(n("CA")));
assertException(ExecutionException.class, () -> dict.get(n("MI")));
assertException(ExecutionException.class, () -> dict.get(n("WI")));
dict.put(n("AR"),null);
dict.put(n("CO"),"Boulder");
dict.put(n("PA"),"Pittsburgh");
assertEquals(3,dict.size());
assertEquals("Pittsburgh",dict.get(n("PA")));
assertEquals("Boulder",dict.get(n("CO")));
assertNull(dict.get(n("AR")));
}
public void test31() {
dict.put(n("GA"),"Atlanta");
dict.put(n("AZ"),"Phoenix");
dict.put(n("VT"),"Montpelier");
assertEquals(3,dict.size());
assertTrue(dict.known(n("AZ")));
assertTrue(dict.known(n("GA")));
assertTrue(dict.known(n("VT")));
assertFalse(dict.known(n("AL")));
assertFalse(dict.known(n("CA")));
assertFalse(dict.known(n("SD")));
assertFalse(dict.known(n("WY")));
assertEquals("Phoenix",dict.get(n("AZ")));
assertEquals("Atlanta",dict.get(n("GA")));
assertEquals("Montpelier",dict.get(n("VT")));
assertException(ExecutionException.class, () -> dict.get(n("AL")));
assertException(ExecutionException.class, () -> dict.get(n("CA")));
assertException(ExecutionException.class, () -> dict.get(n("SD")));
assertException(ExecutionException.class, () -> dict.get(n("WY")));
dict.put(n("AZ"),"Tucson");
dict.put(n("GA"),"Athens");
dict.put(n("VT"),null);
assertEquals(3,dict.size());
assertEquals("Tucson",dict.get(n("AZ")));
assertEquals("Athens",dict.get(n("GA")));
assertNull(dict.get(n("VT")));
}
public void test32() {
dict.put(n("DE"),"Dover");
dict.put(n("SD"),"Pierre");
dict.put(n("AK"),"Juneau");
assertEquals(3,dict.size());
assertTrue(dict.known(n("AK")));
assertTrue(dict.known(n("DE")));
assertTrue(dict.known(n("SD")));
assertFalse(dict.known(n("AB")));
assertFalse(dict.known(n("AZ")));
assertFalse(dict.known(n("MO")));
assertFalse(dict.known(n("WI")));
assertEquals("Juneau",dict.get(n("AK")));
assertEquals("Dover",dict.get(n("DE")));
assertEquals("Pierre",dict.get(n("SD")));
assertException(ExecutionException.class, () -> dict.get(n("AB")));
assertException(ExecutionException.class, () -> dict.get(n("AZ")));
assertException(ExecutionException.class, () -> dict.get(n("MO")));
assertException(ExecutionException.class, () -> dict.get(n("WI")));
dict.put(n("AK"),"Anchorage");
dict.put(n("DE"),"Wilmington");
dict.put(n("SD"),null);
assertEquals(3,dict.size());
assertEquals("Anchorage",dict.get(n("AK")));
assertEquals("Wilmington",dict.get(n("DE")));
assertNull(dict.get(n("SD")));
}
public void test33() {
dict.put(n("WI"),"Madison");
dict.put(n("MN"),"Saint Paul");
dict.put(n("IN"),"Indianapolis");
assertEquals(3,dict.size());
assertTrue(dict.known(n("IN")));
assertTrue(dict.known(n("MN")));
assertTrue(dict.known(n("WI")));
assertFalse(dict.known(n("AK")));
assertFalse(dict.known(n("CO")));
assertFalse(dict.known(n("SD")));
assertFalse(dict.known(n("WY")));
assertEquals("Indianapolis",dict.get(n("IN")));
assertEquals("Saint Paul",dict.get(n("MN")));
assertEquals("Madison",dict.get(n("WI")));
assertException(ExecutionException.class, () -> dict.get(n("AK")));
assertException(ExecutionException.class, () -> dict.get(n("CO")));
assertException(ExecutionException.class, () -> dict.get(n("SD")));
assertException(ExecutionException.class, () -> dict.get(n("WY")));
dict.put(n("IN"),null);
dict.put(n("MN"),"Minneapolis");
dict.put(n("WI"),"Milwaukee");
assertEquals(3,dict.size());
assertEquals("Minneapolis",dict.get(n("MN")));
assertEquals("Milwaukee",dict.get(n("WI")));
assertNull(dict.get(n("IN")));
}
public void test34() {
dict.put(n("RI"),"Providence");
dict.put(n("CA"),"Sacramento");
dict.put(n("MS"),"Jackson");
assertEquals(3,dict.size());
assertTrue(dict.known(n("CA")));
assertTrue(dict.known(n("MS")));
assertTrue(dict.known(n("RI")));
assertFalse(dict.known(n("AK")));
assertFalse(dict.known(n("GA")));
assertFalse(dict.known(n("MT")));
assertFalse(dict.known(n("SD")));
assertEquals("Sacramento",dict.get(n("CA")));
assertEquals("Jackson",dict.get(n("MS")));
assertEquals("Providence",dict.get(n("RI")));
assertException(ExecutionException.class, () -> dict.get(n("AK")));
assertException(ExecutionException.class, () -> dict.get(n("GA")));
assertException(ExecutionException.class, () -> dict.get(n("MT")));
assertException(ExecutionException.class, () -> dict.get(n("SD")));
dict.put(n("CA"),"Los Angeles");
dict.put(n("RI"),"Bristol");
dict.put(n("MS"),null);
assertEquals(3,dict.size());
assertEquals("Los Angeles",dict.get(n("CA")));
assertEquals("Bristol",dict.get(n("RI")));
assertNull(dict.get(n("MS")));
}
public void test35() {
dict.put(n("CT"),"Hartford");
dict.put(n("WY"),"Cheyenne");
dict.put(n("SC"),"Columbia");
assertEquals(3,dict.size());
assertTrue(dict.known(n("CT")));
assertTrue(dict.known(n("SC")));
assertTrue(dict.known(n("WY")));
assertFalse(dict.known(n("CA")));
assertFalse(dict.known(n("MA")));
assertFalse(dict.known(n("UT")));
assertFalse(dict.known(n("YE")));
assertEquals("Hartford",dict.get(n("CT")));
assertEquals("Columbia",dict.get(n("SC")));
assertEquals("Cheyenne",dict.get(n("WY")));
assertException(ExecutionException.class, () -> dict.get(n("CA")));
assertException(ExecutionException.class, () -> dict.get(n("MA")));
assertException(ExecutionException.class, () -> dict.get(n("UT")));
assertException(ExecutionException.class, () -> dict.get(n("YE")));
dict.put(n("CT"),"New York");
dict.put(n("SC"),"Charleston");
dict.put(n("WY"),null);
assertEquals(3,dict.size());
assertEquals("New York",dict.get(n("CT")));
assertEquals("Charleston",dict.get(n("SC")));
assertNull(dict.get(n("WY")));
}
public void test36() {
dict.put(n("KY"),"Frankfort");
dict.put(n("IA"),"Des Moines");
dict.put(n("WI"),"Madison");
dict.put(n("MN"),"Saint Paul");
dict.put(n("IN"),"Indianapolis");
assertEquals(5,dict.size());
assertTrue(dict.known(n("IA")));
assertTrue(dict.known(n("IN")));
assertTrue(dict.known(n("KY")));
assertTrue(dict.known(n("MN")));
assertTrue(dict.known(n("WI")));
assertFalse(dict.known(n("CT")));
assertFalse(dict.known(n("IL")));
assertFalse(dict.known(n("KS")));
assertFalse(dict.known(n("MA")));
assertFalse(dict.known(n("SD")));
assertFalse(dict.known(n("WY")));
assertEquals("Des Moines",dict.get(n("IA")));
assertEquals("Indianapolis",dict.get(n("IN")));
assertEquals("Frankfort",dict.get(n("KY")));
assertEquals("Saint Paul",dict.get(n("MN")));
assertEquals("Madison",dict.get(n("WI")));
assertException(ExecutionException.class, () -> dict.get(n("CT")));
assertException(ExecutionException.class, () -> dict.get(n("IL")));
assertException(ExecutionException.class, () -> dict.get(n("KS")));
assertException(ExecutionException.class, () -> dict.get(n("MA")));
assertException(ExecutionException.class, () -> dict.get(n("SD")));
assertException(ExecutionException.class, () -> dict.get(n("WY")));
dict.put(n("IA"),"Ames");
dict.put(n("KY"),"Lexington");
dict.put(n("IN"),null);
dict.put(n("MN"),"Minneapolis");
dict.put(n("WI"),"Milwaukee");
assertEquals(5,dict.size());
assertEquals("Ames",dict.get(n("IA")));
assertEquals("Lexington",dict.get(n("KY")));
assertEquals("Minneapolis",dict.get(n("MN")));
assertEquals("Milwaukee",dict.get(n("WI")));
assertNull(dict.get(n("IN")));
}
public void test37() {
dict.put(n("MA"),"Boston");
dict.put(n("TN"),"Nashville");
dict.put(n("UT"),"Salt Lake City");
dict.put(n("ID"),"Boise");
dict.put(n("AL"),"Montgomery");
assertEquals(5,dict.size());
assertTrue(dict.known(n("AL")));
assertTrue(dict.known(n("ID")));
assertTrue(dict.known(n("MA")));
assertTrue(dict.known(n("TN")));
assertTrue(dict.known(n("UT")));
assertFalse(dict.known(n("AB")));
assertFalse(dict.known(n("BC")));
assertFalse(dict.known(n("IJ")));
assertFalse(dict.known(n("ON")));
assertFalse(dict.known(n("TU")));
assertFalse(dict.known(n("YT")));
assertEquals("Montgomery",dict.get(n("AL")));
assertEquals("Boise",dict.get(n("ID")));
assertEquals("Boston",dict.get(n("MA")));
assertEquals("Nashville",dict.get(n("TN")));
assertEquals("Salt Lake City",dict.get(n("UT")));
assertException(ExecutionException.class, () -> dict.get(n("AB")));
assertException(ExecutionException.class, () -> dict.get(n("BC")));
assertException(ExecutionException.class, () -> dict.get(n("IJ")));
assertException(ExecutionException.class, () -> dict.get(n("ON")));
assertException(ExecutionException.class, () -> dict.get(n("TU")));
assertException(ExecutionException.class, () -> dict.get(n("YT")));
dict.put(n("AL"),"Birmingham");
dict.put(n("ID"),null);
dict.put(n("MA"),"Amherst");
dict.put(n("TN"),"Memphis");
dict.put(n("UT"),null);
assertEquals(5,dict.size());
assertEquals("Birmingham",dict.get(n("AL")));
assertNull(dict.get(n("ID")));
assertEquals("Amherst",dict.get(n("MA")));
assertEquals("Memphis",dict.get(n("TN")));
assertNull(dict.get(n("UT")));
}
public void test38() {
dict.put(n("MD"),"Annapolis");
dict.put(n("KS"),"Topeka");
dict.put(n("HI"),"Honolulu");
dict.put(n("LA"),"Baton Rouge");
dict.put(n("OR"),"Salem");
dict.put(n("MO"),"Jefferson City");
dict.put(n("WA"),"Olympia");
assertEquals(7,dict.size());
assertTrue(dict.known(n("HI")));
assertTrue(dict.known(n("KS")));
assertTrue(dict.known(n("LA")));
assertTrue(dict.known(n("MD")));
assertTrue(dict.known(n("MO")));
assertTrue(dict.known(n("OR")));
assertTrue(dict.known(n("WA")));
assertFalse(dict.known(n("FL")));
assertFalse(dict.known(n("K")));
assertFalse(dict.known(n("L")));
assertFalse(dict.known(n("MB")));
assertFalse(dict.known(n("MT")));
assertFalse(dict.known(n("NB")));
assertFalse(dict.known(n("QC")));
assertFalse(dict.known(n("YT")));
assertEquals("Honolulu",dict.get(n("HI")));
assertEquals("Topeka",dict.get(n("KS")));
assertEquals("Baton Rouge",dict.get(n("LA")));
assertEquals("Annapolis",dict.get(n("MD")));
assertEquals("Jefferson City",dict.get(n("MO")));
assertEquals("Salem",dict.get(n("OR")));
assertEquals("Olympia",dict.get(n("WA")));
assertException(ExecutionException.class, () -> dict.get(n("FL")));
assertException(ExecutionException.class, () -> dict.get(n("K")));
assertException(ExecutionException.class, () -> dict.get(n("L")));
assertException(ExecutionException.class, () -> dict.get(n("MB")));
assertException(ExecutionException.class, () -> dict.get(n("MT")));
assertException(ExecutionException.class, () -> dict.get(n("NB")));
assertException(ExecutionException.class, () -> dict.get(n("QC")));
assertException(ExecutionException.class, () -> dict.get(n("YK")));
dict.put(n("HI"),null);
dict.put(n("KS"),"Kansas City");
dict.put(n("LA"),"New Orleans");
dict.put(n("MD"),"Baltimore");
dict.put(n("MO"),"Kansas City");
dict.put(n("OR"),"Portland");
dict.put(n("WA"),"Seattle");
assertEquals(7,dict.size());
assertNull(dict.get(n("HI")));
assertEquals("Kansas City",dict.get(n("KS")));
assertEquals("New Orleans",dict.get(n("LA")));
assertEquals("Baltimore",dict.get(n("MD")));
assertEquals("Kansas City",dict.get(n("MO")));
assertEquals("Portland",dict.get(n("OR")));
assertEquals("Seattle",dict.get(n("WA")));
}
public void test40() {
dict.put(n("NY"),"Albany");
dict.put(n("MD"),"Annapolis");
dict.put(n("GA"),"Atlanta");
dict.put(n("ME"),"Augusta");
dict.put(n("TX"),"Austin");
dict.put(n("LA"),"Baton Rouge");
dict.put(n("ND"),"Bismarck");
dict.put(n("ID"),"Boise");
dict.put(n("MA"),"Boston");
dict.put(n("NV"),"Carson City");
dict.put(n("WV"),"Charleston");
dict.put(n("WY"),"Cheyenne");
dict.put(n("SC"),"Columbia");
dict.put(n("OH"),"Columbus");
dict.put(n("NH"),"Concord");
dict.put(n("CO"),"Denver");
dict.put(n("IA"),"Des Moines");
dict.put(n("DE"),"Dover");
dict.put(n("KY"),"Frankfort");
dict.put(n("PA"),"Harrisburg");
dict.put(n("CT"),"Hartford");
dict.put(n("MT"),"Helena");
dict.put(n("HI"),"Honolulu");
dict.put(n("IN"),"Indianapolis");
dict.put(n("MS"),"Jackson");
assertEquals(25,dict.size());
}
public void test41() {
dict.put(n("NY"),"Albany");
dict.put(n("MD"),"Annapolis");
dict.put(n("GA"),"Atlanta");
dict.put(n("ME"),"Augusta");
dict.put(n("TX"),"Austin");
dict.put(n("LA"),"Baton Rouge");
dict.put(n("ND"),"Bismarck");
dict.put(n("ID"),"Boise");
dict.put(n("MA"),"Boston");
dict.put(n("NV"),"Carson City");
dict.put(n("WV"),"Charleston");
dict.put(n("WY"),"Cheyenne");
dict.put(n("SC"),"Columbia");
dict.put(n("OH"),"Columbus");
dict.put(n("NH"),"Concord");
dict.put(n("CO"),"Denver");
dict.put(n("IA"),"Des Moines");
dict.put(n("DE"),"Dover");
dict.put(n("KY"),"Frankfort");
dict.put(n("PA"),"Harrisburg");
dict.put(n("CT"),"Hartford");
dict.put(n("MT"),"Helena");
dict.put(n("HI"),"Honolulu");
dict.put(n("IN"),"Indianapolis");
dict.put(n("MS"),"Jackson");
assertTrue(dict.known(n("CO")));
assertTrue(dict.known(n("CT")));
assertTrue(dict.known(n("DE")));
assertTrue(dict.known(n("GA")));
assertTrue(dict.known(n("HI")));
assertTrue(dict.known(n("IA")));
assertTrue(dict.known(n("ID")));
assertTrue(dict.known(n("IN")));
assertTrue(dict.known(n("KY")));
assertTrue(dict.known(n("LA")));
assertTrue(dict.known(n("MA")));
assertTrue(dict.known(n("MD")));
assertTrue(dict.known(n("ME")));
assertTrue(dict.known(n("MS")));
assertTrue(dict.known(n("MT")));
assertTrue(dict.known(n("ND")));
assertTrue(dict.known(n("NH")));
assertTrue(dict.known(n("NV")));
assertTrue(dict.known(n("NY")));
assertTrue(dict.known(n("OH")));
assertTrue(dict.known(n("PA")));
assertTrue(dict.known(n("SC")));
assertTrue(dict.known(n("TX")));
assertTrue(dict.known(n("WV")));
assertTrue(dict.known(n("WY")));
}
public void test42() {
dict.put(n("NY"),"Albany");
dict.put(n("MD"),"Annapolis");
dict.put(n("GA"),"Atlanta");
dict.put(n("ME"),"Augusta");
dict.put(n("TX"),"Austin");
dict.put(n("LA"),"Baton Rouge");
dict.put(n("ND"),"Bismarck");
dict.put(n("ID"),"Boise");
dict.put(n("MA"),"Boston");
dict.put(n("NV"),"Carson City");
dict.put(n("WV"),"Charleston");
dict.put(n("WY"),"Cheyenne");
dict.put(n("SC"),"Columbia");
dict.put(n("OH"),"Columbus");
dict.put(n("NH"),"Concord");
dict.put(n("CO"),"Denver");
dict.put(n("IA"),"Des Moines");
dict.put(n("DE"),"Dover");
dict.put(n("KY"),"Frankfort");
dict.put(n("PA"),"Harrisburg");
dict.put(n("CT"),"Hartford");
dict.put(n("MT"),"Helena");
dict.put(n("HI"),"Honolulu");
dict.put(n("IN"),"Indianapolis");
dict.put(n("MS"),"Jackson");
assertFalse(dict.known(n("CA")));
assertFalse(dict.known(n("CS")));
assertFalse(dict.known(n("CZ")));
assertFalse(dict.known(n("FL")));
assertFalse(dict.known(n("GE")));
assertFalse(dict.known(n("HO")));
assertFalse(dict.known(n("IB")));
assertFalse(dict.known(n("IL")));
assertFalse(dict.known(n("KS")));
assertFalse(dict.known(n("L")));
assertFalse(dict.known(n("LB")));
assertFalse(dict.known(n("MB")));
assertFalse(dict.known(n("MDA")));
assertFalse(dict.known(n("MO")));
assertFalse(dict.known(n("MST")));
assertFalse(dict.known(n("NC")));
assertFalse(dict.known(n("NE")));
assertFalse(dict.known(n("NJ")));
assertFalse(dict.known(n("NW")));
assertFalse(dict.known(n("NZ")));
assertFalse(dict.known(n("ON")));
assertFalse(dict.known(n("PE")));
assertFalse(dict.known(n("SK")));
assertFalse(dict.known(n("UT")));
assertFalse(dict.known(n("WWW")));
assertFalse(dict.known(n("YK")));
}
public void test43() {
dict.put(n("NY"),"Albany");
dict.put(n("MD"),"Annapolis");
dict.put(n("GA"),"Atlanta");
dict.put(n("ME"),"Augusta");
dict.put(n("TX"),"Austin");
dict.put(n("LA"),"Baton Rouge");
dict.put(n("ND"),"Bismarck");
dict.put(n("ID"),"Boise");
dict.put(n("MA"),"Boston");
dict.put(n("NV"),"Carson City");
dict.put(n("WV"),"Charleston");
dict.put(n("WY"),"Cheyenne");
dict.put(n("SC"),"Columbia");
dict.put(n("OH"),"Columbus");
dict.put(n("NH"),"Concord");
dict.put(n("CO"),"Denver");
dict.put(n("IA"),"Des Moines");
dict.put(n("DE"),"Dover");
dict.put(n("KY"),"Frankfort");
dict.put(n("PA"),"Harrisburg");
dict.put(n("CT"),"Hartford");
dict.put(n("MT"),"Helena");
dict.put(n("HI"),"Honolulu");
dict.put(n("IN"),"Indianapolis");
dict.put(n("MS"),"Jackson");
assertEquals("Denver",dict.get(n("CO")));
assertEquals("Hartford",dict.get(n("CT")));
assertEquals("Dover",dict.get(n("DE")));
assertEquals("Atlanta",dict.get(n("GA")));
assertEquals("Honolulu",dict.get(n("HI")));
assertEquals("Des Moines",dict.get(n("IA")));
assertEquals("Boise",dict.get(n("ID")));
assertEquals("Indianapolis",dict.get(n("IN")));
assertEquals("Frankfort",dict.get(n("KY")));
assertEquals("Baton Rouge",dict.get(n("LA")));
assertEquals("Boston",dict.get(n("MA")));
assertEquals("Annapolis",dict.get(n("MD")));
assertEquals("Augusta",dict.get(n("ME")));
assertEquals("Jackson",dict.get(n("MS")));
assertEquals("Helena",dict.get(n("MT")));
assertEquals("Bismarck",dict.get(n("ND")));
assertEquals("Concord",dict.get(n("NH")));
assertEquals("Carson City",dict.get(n("NV")));
assertEquals("Albany",dict.get(n("NY")));
assertEquals("Columbus",dict.get(n("OH")));
assertEquals("Harrisburg",dict.get(n("PA")));
assertEquals("Columbia",dict.get(n("SC")));
assertEquals("Austin",dict.get(n("TX")));
assertEquals("Charleston",dict.get(n("WV")));
assertEquals("Cheyenne",dict.get(n("WY")));
}
public void test44() {
dict.put(n("NY"),"Albany");
dict.put(n("MD"),"Annapolis");
dict.put(n("GA"),"Atlanta");
dict.put(n("ME"),"Augusta");
dict.put(n("TX"),"Austin");
dict.put(n("LA"),"Baton Rouge");
dict.put(n("ND"),"Bismarck");
dict.put(n("ID"),"Boise");
dict.put(n("MA"),"Boston");
dict.put(n("NV"),"Carson City");
dict.put(n("WV"),"Charleston");
dict.put(n("WY"),"Cheyenne");
dict.put(n("SC"),"Columbia");
dict.put(n("OH"),"Columbus");
dict.put(n("NH"),"Concord");
dict.put(n("CO"),"Denver");
dict.put(n("IA"),"Des Moines");
dict.put(n("DE"),"Dover");
dict.put(n("KY"),"Frankfort");
dict.put(n("PA"),"Harrisburg");
dict.put(n("CT"),"Hartford");
dict.put(n("MT"),"Helena");
dict.put(n("HI"),"Honolulu");
dict.put(n("IN"),"Indianapolis");
dict.put(n("MS"),"Jackson");
assertException(ExecutionException.class, () -> dict.get(n("CA")));
assertException(ExecutionException.class, () -> dict.get(n("CS")));
assertException(ExecutionException.class, () -> dict.get(n("CZ")));
assertException(ExecutionException.class, () -> dict.get(n("FL")));
assertException(ExecutionException.class, () -> dict.get(n("GE")));
assertException(ExecutionException.class, () -> dict.get(n("HO")));
assertException(ExecutionException.class, () -> dict.get(n("IB")));
assertException(ExecutionException.class, () -> dict.get(n("IL")));
assertException(ExecutionException.class, () -> dict.get(n("KS")));
assertException(ExecutionException.class, () -> dict.get(n("L")));
assertException(ExecutionException.class, () -> dict.get(n("LB")));
assertException(ExecutionException.class, () -> dict.get(n("MB")));
assertException(ExecutionException.class, () -> dict.get(n("MDA")));
assertException(ExecutionException.class, () -> dict.get(n("MO")));
assertException(ExecutionException.class, () -> dict.get(n("MST")));
assertException(ExecutionException.class, () -> dict.get(n("NC")));
assertException(ExecutionException.class, () -> dict.get(n("NE")));
assertException(ExecutionException.class, () -> dict.get(n("NJ")));
assertException(ExecutionException.class, () -> dict.get(n("NW")));
assertException(ExecutionException.class, () -> dict.get(n("NZ")));
assertException(ExecutionException.class, () -> dict.get(n("ON")));
assertException(ExecutionException.class, () -> dict.get(n("PE")));
assertException(ExecutionException.class, () -> dict.get(n("SK")));
assertException(ExecutionException.class, () -> dict.get(n("UT")));
assertException(ExecutionException.class, () -> dict.get(n("WWW")));
assertException(ExecutionException.class, () -> dict.get(n("YK")));
}
public void test45() {
dict.put(n("NY"),"Albany");
dict.put(n("MD"),"Annapolis");
dict.put(n("GA"),"Atlanta");
dict.put(n("ME"),"Augusta");
dict.put(n("TX"),"Austin");
dict.put(n("LA"),"Baton Rouge");
dict.put(n("ND"),"Bismarck");
dict.put(n("ID"),"Boise");
dict.put(n("MA"),"Boston");
dict.put(n("NV"),"Carson City");
dict.put(n("WV"),"Charleston");
dict.put(n("WY"),"Cheyenne");
dict.put(n("SC"),"Columbia");
dict.put(n("OH"),"Columbus");
dict.put(n("NH"),"Concord");
dict.put(n("CO"),"Denver");
dict.put(n("IA"),"Des Moines");
dict.put(n("DE"),"Dover");
dict.put(n("KY"),"Frankfort");
dict.put(n("PA"),"Harrisburg");
dict.put(n("CT"),"Hartford");
dict.put(n("MT"),"Helena");
dict.put(n("HI"),"Honolulu");
dict.put(n("IN"),"Indianapolis");
dict.put(n("MS"),"Jackson");
dict.put(n("NY"),"New York");
dict.put(n("MD"),"Baltimore");
dict.put(n("GA"),"Athens");
dict.put(n("ME"),"Portland");
dict.put(n("TX"),"Houston");
dict.put(n("LA"),"New Orleans");
dict.put(n("ND"),"");
dict.put(n("ID"),null);
dict.put(n("MA"),"Lexington");
dict.put(n("NV"),"Las Vegas");
dict.put(n("WV"),"");
dict.put(n("WY"),null);
dict.put(n("SC"),"Charleston");
dict.put(n("OH"),"Cincinnati");
dict.put(n("NH"),"Manchester");
dict.put(n("CO"),"Boulder");
dict.put(n("IA"),"Ames");
dict.put(n("DE"),"Wilmington");
dict.put(n("KY"),"Louisville");
dict.put(n("PA"),"Philadelphia");
dict.put(n("CT"),"Bridgeport");
dict.put(n("MT"),"Billings");
dict.put(n("HI"),"Hawaii City");
dict.put(n("IN"),"Gary");
dict.put(n("MS"),"");
assertEquals("Boulder",dict.get(n("CO")));
assertEquals("Bridgeport",dict.get(n("CT")));
assertEquals("Wilmington",dict.get(n("DE")));
assertEquals("Athens",dict.get(n("GA")));
assertEquals("Hawaii City",dict.get(n("HI")));
assertEquals("Ames",dict.get(n("IA")));
assertEquals(null,dict.get(n("ID")));
assertEquals("Gary",dict.get(n("IN")));
assertEquals("Louisville",dict.get(n("KY")));
assertEquals("New Orleans",dict.get(n("LA")));
assertEquals("Lexington",dict.get(n("MA")));
assertEquals("Baltimore",dict.get(n("MD")));
assertEquals("Portland",dict.get(n("ME")));
assertEquals("",dict.get(n("MS")));
assertEquals("Billings",dict.get(n("MT")));
assertEquals("",dict.get(n("ND")));
assertEquals("Manchester",dict.get(n("NH")));
assertEquals("Las Vegas",dict.get(n("NV")));
assertEquals("New York",dict.get(n("NY")));
assertEquals("Cincinnati",dict.get(n("OH")));
assertEquals("Philadelphia",dict.get(n("PA")));
assertEquals("Charleston",dict.get(n("SC")));
assertEquals("Houston",dict.get(n("TX")));
assertEquals("",dict.get(n("WV")));
assertEquals(null,dict.get(n("WY")));
}
public void test50() {
Collection c = dict.values();
assertTrue(c.isEmpty());
}
public void test51() {
dict.put(n("France"),"Paris");
Collection c = dict.values();
assertEquals(1,c.size());
assertTrue(c.contains("Paris"));
}
public void test52() {
dict.put(n("Germany"),"Berlin");
dict.put(n("Switzerland"),"Bern");
Collection c = dict.values();
assertEquals(2,c.size());
assertTrue(c.contains("Berlin"));
assertTrue(c.contains("Bern"));
}
public void test53() {
dict.put(n("Spain"),"Madrid");
dict.put(n("Italy"),"Rome");
dict.put(n("Portugal"),"Lisbon");
Collection c = dict.values();
assertEquals(3,c.size());
assertTrue(c.contains("Madrid"));
assertTrue(c.contains("Rome"));
assertTrue(c.contains("Lisbon"));
}
public void test54() {
dict.put(n("test"),null);
dict.put(n("TEST"),null);
Collection c = dict.values();
assertEquals(2,c.size());
assertTrue(c.contains(null));
Iterator it = c.iterator();
assertNull(it.next());
assertNull(it.next());
}
public void test55() {
dict.put(n("Slovakia"),"Bratislava");
dict.put(n("Czech"),"Prague");
Collection c = dict.values();
assertEquals(2,c.size());
Iterator it = c.iterator();
assertEquals("Bratislava",it.next());
assertEquals("Prague",it.next());
}
public void test56() {
dict.put(n("Slovenia"), "Ljubljana");
dict.put(n("Croatia"), "Zagreb");
dict.put(n("Macedonia"), "Skopje");
dict.put(n("Bosnia & Hercegovina"), "Sarajevo");
dict.put(n("Montenegro"), "Titograd");
dict.put(n("Serbia"), "Belgrade");
dict.put(n("Kosovo"), "Pristina");
Collection c = dict.values();
assertEquals(7,c.size());
Iterator it = c.iterator();
assertEquals("Ljubljana",it.next());
assertEquals("Skopje",it.next());
assertEquals("Zagreb",it.next());
assertEquals("Sarajevo",it.next());
assertEquals("Titograd",it.next());
assertEquals("Pristina",it.next());
assertEquals("Belgrade",it.next());
}
public void test60() {
String s= dict.toString();
assertTrue("Doesn't start with with <<: '" + s + "'",s.startsWith("<<"));
assertTrue("Doesn't end with with >>: '" + s + "'",s.endsWith(">>"));
s = s.substring(2,s.length()-2);
assertTrue("Has extraneous non-space characters: '" + s + '"',s.trim().isEmpty());
}
public void test61() {
dict.put(n("CS-250"),"Sorenson");
String s= dict.toString();
assertTrue("Doesn't start with with <<: '" + s + "'",s.startsWith("<<"));
assertTrue("Doesn't end with with >>: '" + s + "'",s.endsWith(">>"));
s = s.substring(2,s.length()-2).trim();
String[] pieces = s.split(" ");
assertEquals("should have two parts: '" + s + "'",2,pieces.length);
assertEquals("/CS-250",pieces[0]);
assertEquals("Sorenson",pieces[1]);
}
public void test62() {
dict.put(n("CS-240"),"McNally");
dict.put(n("CS-150"),"Rock");
String s= dict.toString();
s = s.substring(2,s.length()-2).trim();
String[] pieces = s.split(" ");
assertEquals("should have four parts: '" + s + "'",4,pieces.length);
assertEquals("/CS-240",pieces[0]);
assertEquals("McNally",pieces[1]);
assertEquals("/CS-150",pieces[2]);
assertEquals("Rock",pieces[3]);
}
public void test63() {
dict.put(n("CS-315"),"McNally");
dict.put(n("CS-251"),"Zhao");
dict.put(n("CS-251"),"Sorenson");
dict.put(n("CS-337"),"Sorenson");
dict.put(n("CS-337"),"Rock");
String s= dict.toString();
assertTrue("Doesn't start with with <<: '" + s + "'",s.startsWith("<<"));
assertTrue("Doesn't end with with >>: '" + s + "'",s.endsWith(">>"));
s = s.substring(2,s.length()-2).trim();
String[] pieces = s.split(" ");
assertEquals("should have six parts: '" + s + "'",6,pieces.length);
assertEquals("/CS-251",pieces[0]);
assertEquals("Sorenson",pieces[1]);
assertEquals("/CS-315",pieces[2]);
assertEquals("McNally",pieces[3]);
assertEquals("/CS-337",pieces[4]);
assertEquals("Rock",pieces[5]);
}
public void test64() {
dict.put(n("1c"),2.5);
dict.put(n("5"),null);
String s= dict.toString();
s = s.substring(2,s.length()-2).trim();
String[] pieces = s.split(" ");
assertEquals("should have four parts: '" + s + "'",4,pieces.length);
assertEquals("/1c",pieces[0]);
assertEquals("2.5",pieces[1]);
assertEquals("/5",pieces[2]);
assertEquals("null",pieces[3]);
}
public void test67() {
dict.put(n("CS-351"),"Boyland");
dict.put(n("CS-417"),"Chen");
dict.put(n("CS-458"),"Eggebeen");
dict.put(n("CS-422"),"Mali");
dict.put(n("CS-535"),"Cheng");
dict.put(n("CS-469"),"Xu");
dict.put(n("CS-431"),"Zhao");
String s= dict.toString();
s = s.substring(2,s.length()-2).trim();
String[] pieces = s.split(" ");
assertEquals("should have fourteen parts: '" + s + "'",14,pieces.length);
assertEquals("/CS-351",pieces[0]);
assertEquals("Boyland",pieces[1]);
assertEquals("/CS-431",pieces[2]);
assertEquals("Zhao",pieces[3]);
assertEquals("/CS-422",pieces[4]);
assertEquals("Mali",pieces[5]);
assertEquals("/CS-535",pieces[6]);
assertEquals("Cheng",pieces[7]);
assertEquals("/CS-458",pieces[8]);
assertEquals("Eggebeen",pieces[9]);
assertEquals("/CS-469",pieces[10]);
assertEquals("Xu",pieces[11]);
assertEquals("/CS-417",pieces[12]);
assertEquals("Chen",pieces[13]);
}
public void test70() {
dict.copy(dict);
assertEquals(0,dict.size());
}
public void test71() {
Dictionary dict2 = new Dictionary();
dict.put(n("Hello"),"Hallo");
dict2.put(n("Good day"),"Guten Tag");
assertEquals(1,dict.size());
assertEquals(1,dict2.size());
dict.copy(dict2);
assertEquals(2,dict.size());
assertEquals(1,dict2.size());
assertEquals("Guten Tag",dict.get(n("Good day")));
assertEquals("Hallo",dict.get(n("Hello")));
}
public void test72() {
Dictionary dict2 = new Dictionary();
dict.put(n("Hello"),"Hallo");
dict2.put(n("Hello"),"Guten Tag");
assertEquals(1,dict.size());
assertEquals(1,dict2.size());
dict.copy(dict2);
assertEquals(1,dict.size());
assertEquals(1,dict2.size());
assertEquals("Guten Tag",dict.get(n("Hello")));
}
public void test73() {
dict.put(n("Hello"),"Bonjour");
dict.copy(dict);
assertEquals(1,dict.size());
assertEquals("Bonjour",dict.get(n("Hello")));
}
public void test74() {
Dictionary dict2 = new Dictionary();
dict.put(n("Bye"),null);
dict2.put(n("Bye"),"");
dict2.copy(dict);
assertNull(dict2.get(n("Bye")));
dict2.put(n("Bye"),"");
assertNull(dict.get(n("Bye")));
dict.copy(dict2);
assertEquals(1,dict.size());
assertEquals("",dict.get(n("Bye")));
}
public void test75() {
Dictionary dict2 = new Dictionary();
dict.put(n("A"),"1");
dict2.put(n("B"),"2");
dict.copy(dict2);
dict.put(n("C"),"3");
assertEquals(3,dict.size());
assertEquals(1,dict2.size());
assertFalse(dict2.known(n("A")));
assertFalse(dict2.known(n("C")));
}
public void test76() {
Dictionary dict2 = new Dictionary();
dict.put(n("A"),"1");
dict.put(n("B"),"2");
dict2.put(n("A"),1);
dict2.put(n("C"),3);
dict.copy(dict2);
assertEquals(3,dict.size());
assertEquals(2,dict2.size());
dict2.copy(dict);
assertEquals(3,dict2.size());
dict.copy(dict2);
assertEquals(3,dict.size());
assertEquals(1,dict.get(n("A")));
assertEquals("2",dict.get(n("B")));
assertEquals(3,dict.get(n("C")));
}
public void test78() {
Dictionary dict2 = new Dictionary();
dict.put(n("CS-315"),"McNally");
dict.put(n("CS-240"),"McNally");
dict.put(n("CS-337"),"Sorenson");
dict.put(n("CS-202"),"Rock");
dict.put(n("CS-251"),"Sorenson");
dict.put(n("CS-361"),"Rock");
dict2.put(n("CS-315"),"McNally");
dict2.put(n("CS-150"),"Rock");
dict2.put(n("CS-337"),"Rock");
dict2.put(n("CS-241"),"Sorenson");
dict2.put(n("CS-250"),"Sorenson");
dict2.put(n("CS-151"),"McNally");
dict.copy(dict2);
assertEquals(10,dict.size());
assertEquals("Rock",dict.get(n("CS-337")));
assertEquals("Sorenson",dict.get(n("CS-251")));
assertEquals("McNally",dict.get(n("CS-151")));
}
}
TEST DICTIONARY AS MAP
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Set;
import edu.uwm.cs351.ps.Dictionary;
import edu.uwm.cs351.ps.ExecutionException;
import edu.uwm.cs351.ps.Name;
import edu.uwm.cs351.util.AbstractEntry;
import junit.framework.TestCase;
@SuppressWarnings("unlikely-arg-type")
public class TestDictionaryAsMap extends TestCase {
protected void assertException(Class c, Runnable r) {
try {
r.run();
assertFalse("Exception should have been thrown",true);
} catch (RuntimeException ex) {
assertTrue("should throw exception of " + c + ", not of " + ex.getClass(), c.isInstance(ex));
}
}
protected Map d1;
protected Iterator> it, it2;
protected Entry e, e2;
@Override
protected void setUp() {
try {
assert d1.get(null) == d1;
throw new IllegalStateException("assertions must be enabled to run this test");
} catch (NullPointerException ex) {
// OK!
}
d1 = new Dictionary();
}
/// convenience methods for creating names (n), and entries (e)
protected Name n(String s) { return new Name(s); }
protected Name n(int i) { return n((""+(1000+i)).substring(1)); }
protected Entry e(T k, U v) {
return new AbstractEntry() {
@Override
public T getKey() {
return k;
}
@Override
public U getValue() {
return v;
}
};
}
/**
* text0XX
* Testing get, put and size
*/
public void test000() {
assertTrue(d1.isEmpty());
}
public void test001() {
assertEquals(0,d1.size());
}
public void test002() {
assertNull(d1.get(n(42))); // NB: Map version does not throw an exception
}
public void test003() {
assertNull(d1.get(42));
}
public void test004() {
assertNull(d1.get("hello"));
}
public void test005() {
assertNull(d1.get(new Object()));
}
public void test006() {
assertNull(d1.get(d1));
}
public void test007() {
assertNull(d1.get(null));
}
public void test008() {
assertException(ExecutionException.class,() -> d1.put(null,"hello"));
}
public void test009() {
assertEquals(0,d1.entrySet().size());
}
public void test010() {
d1.put(n("hello"),8);
assertEquals(1,d1.size());
}
public void test011() {
d1.put(n("bye"),9);
assertNull(d1.get(n("hello")));
assertNull(d1.get(n("apples")));
}
public void test012() {
d1.put(n("time"), 10.30);
assertNull(d1.get("time"));
assertNull(d1.get(10.30));
}
public void test013() {
d1.put(n("WI"), "Madison");
assertNull(d1.get(n("Wi")));
}
public void test014() {
d1.put(n("apples"),10);
assertNull(d1.get(null));
}
public void test015() {
d1.put(n("candy"),null);
assertNull(d1.get("candy"));
}
public void test016() {
d1.put(n("bacon"),null);
assertEquals(1,d1.size());
}
public void test017() {
d1.put(n(""),"");
assertEquals("",d1.get(n("")));
}
public void test018() {
Collection c = d1.values();
d1.put(n(""), n("\0"));
assertNull(d1.get("\0"));
assertEquals(1,c.size()); // making sure you deleted bad definition of "values()"
}
public void test019() {
Object x = d1.put(n("hello"),42);
assertNull(x);
}
public void test020() {
d1.put(n("apples"),5);
d1.put(n("apples"),10);
assertEquals(Integer.valueOf(10),d1.get(n("apples")));
}
public void test021() {
d1.put(n("CA"),"San Francisco");
d1.put(n("CA"),"Sacramento");
assertEquals(1,d1.size());
}
public void test022() {
d1.put(n("hello"),"bye");
Object x = d1.put(n("hello"),"world");
assertEquals("bye",x);
}
public void test023() {
d1.put(n("MI"),"Detroit");
d1.put(n("MI"), "Lansing");
assertEquals("Lansing",d1.get(n("MI")));
}
public void test024() {
d1.put(n("hello"),null);
d1.put(n("hello"),"bye");
assertEquals("bye",d1.get(n("hello")));
}
public void test025() {
d1.put(n("Candy"),0);
d1.put(n("Candy"),null);
assertNull(d1.get(n("Candy")));
assertEquals(1,d1.size());
}
public void test026() {
d1.put(n("WI"),"Madison");
d1.put(n("IL"),"Springfield");
assertEquals(2,d1.size());
assertEquals("Madison",d1.get(n("WI")));
assertEquals("Springfield",d1.get(n("IL")));
}
public void test027() {
d1.put(n("CA"),"Sacramento");
d1.put(n("NV"),"Carson City");
assertEquals("Carson City",d1.get(n("NV")));
}
public void test028() {
d1.put(n("IL"),"Springfield");
d1.put(n("WI"), "Madison");
assertNull(d1.get(n("MI")));
assertNull(d1.get(n("ND")));
assertNull(d1.get(n("YK")));
}
public void test029() {
d1.put(n("TX"),"Austin");
d1.put(n("FL"),"Tallahassee");
assertNull(d1.get(n("WI")));
assertNull(d1.get(n("CA")));
assertNull(d1.get(n("MO")));
}
public void test030() {
d1.put(n("ND"),"Bismarck");
Object x = d1.put(n("SD"),"Pierre");
assertNull(x);
}
public void test031() {
d1.put(n("ND"),"Bismarck");
d1.put(n("SD"),"Sioux Falls");
Object x = d1.put(n("SD"),"Pierre");
assertEquals("Sioux Falls",x);
}
public void test032() {
d1.put(n("ND"),"Bismarck");
d1.put(n("SD"),"Sioux Falls");
d1.put(n("SD"),"Pierre");
assertEquals(2,d1.size());
}
public void test033() {
d1.put(n("ND"),"Bismarck");
d1.put(n("SD"),"Sioux Falls");
d1.put(n("SD"),"Pierre");
assertEquals("Pierre",d1.get(n("SD")));
}
public void test034() {
d1.put(n("IN"),"Indianapolis");
d1.put(n("OH"),"Columbus");
d1.put(n("IN"),"Gary");
assertEquals(2,d1.size());
}
public void test035() {
d1.put(n("IN"),"Indianapolis");
d1.put(n("OH"),"Columbus");
d1.put(n("IN"),"Gary");
assertEquals("Gary",d1.get(n("IN")));
}
public void test036() {
d1.put(n("IN"),"Indianapolis");
d1.put(n("OH"),"Columbus");
Object x = d1.put(n("IN"),"Gary");
assertEquals("Indianapolis",x);
}
public void test037() {
d1.put(n("IL"),"Springfield");
d1.put(n("WI"),"Madison");
d1.put(n("IL"),"Chicago");
d1.put(n("WI"),"Milwaukee");
Object x = d1.put(n("WI"),"Madison");
assertEquals("Milwaukee",x);
}
public void test038() {
d1.put(n("IL"),"Springfield");
d1.put(n("WI"),"Madison");
d1.put(n("IL"),"Chicago");
d1.put(n("WI"),"Milwaukee");
d1.put(n("WI"),"Madison");
Object x = d1.put(n("IL"),"Springfield");
assertEquals("Chicago",x);
}
public void test039() {
d1.put(n("IL"),"Springfield");
d1.put(n("WI"),"Madison");
d1.put(n("IL"),"Chicago");
d1.put(n("WI"),"Milwaukee");
d1.put(n("WI"),"Madison");
d1.put(n("IL"),"Springfield");
assertEquals(2,d1.size());
assertEquals("Madison",d1.get(n("WI")));
assertEquals("Springfield",d1.get(n("IL")));
}
public void test040(){
assertNull(d1.put(n("c"), 63));
assertNull(d1.put(n("a"), 61));
assertNull(d1.put(n("f"), 66));
assertNull(d1.put(n("b"), 62));
assertNull(d1.put(n("e"), 65));
assertNull(d1.put(n("d"), 64));
assertNull(d1.put(n("g"), 67));
}
public void test050(){
d1.put(n("c"), 63);
d1.put(n("a"), 61);
d1.put(n("f"), 66);
d1.put(n("b"), 62);
d1.put(n("e"), 65);
d1.put(n("d"), 64);
d1.put(n("g"), 67);
assertEquals(7, d1.size());
assertEquals(Integer.valueOf(61), d1.get(n("a")));
assertEquals(Integer.valueOf(62), d1.get(n("b")));
assertEquals(Integer.valueOf(63), d1.get(n("c")));
assertEquals(Integer.valueOf(64), d1.get(n("d")));
assertEquals(Integer.valueOf(65), d1.get(n("e")));
assertEquals(Integer.valueOf(66), d1.get(n("f")));
assertEquals(Integer.valueOf(67), d1.get(n("g")));
}
public void test060(){
d1.put(n("c"), 63);
d1.put(n("a"), 61);
d1.put(n("f"), 66);
d1.put(n("b"), 62);
d1.put(n("e"), 65);
d1.put(n("d"), 64);
d1.put(n("g"), 67);
assertNull(d1.get(n("")));
assertNull(d1.get(n("aa")));
assertNull(d1.get(n("b\0")));
assertNull(d1.get(n("c ")));
assertNull(d1.get(n("d.")));
assertNull(d1.get(n("eA")));
assertNull(d1.get(n("f0")));
assertNull(d1.get(n("g*")));
}
public void test070(){
d1.put(n("c"), 63);
d1.put(n("a"), 61);
d1.put(n("f"), 66);
d1.put(n("b"), 62);
d1.put(n("e"), 65);
d1.put(n("d"), 64);
d1.put(n("g"), 67);
assertEquals(7, d1.size());
assertEquals(Integer.valueOf(61), d1.put(n("a"), 97));
assertEquals(7, d1.size());
assertEquals(Integer.valueOf(62), d1.put(n("b"), 98));
assertEquals(7, d1.size());
assertEquals(Integer.valueOf(63), d1.put(n("c"), 99));
assertEquals(7, d1.size());
assertEquals(Integer.valueOf(64), d1.put(n("d"), 100));
assertEquals(7, d1.size());
assertEquals(Integer.valueOf(65), d1.put(n("e"), 101));
assertEquals(7, d1.size());
assertEquals(Integer.valueOf(66), d1.put(n("f"), 102));
assertEquals(7, d1.size());
assertEquals(Integer.valueOf(67), d1.put(n("g"), 103));
assertEquals(7, d1.size());
}
public void test080(){
d1.put(n("c"), 63);
d1.put(n("a"), 61);
d1.put(n("f"), 66);
d1.put(n("b"), 62);
d1.put(n("e"), 65);
d1.put(n("d"), 64);
d1.put(n("g"), 67);
d1.put(n("a"), 97);
d1.put(n("b"), 98);
d1.put(n("c"), 99);
d1.put(n("d"), 100);
d1.put(n("e"), 101);
d1.put(n("f"), 102);
d1.put(n("g"), 103);
assertEquals(Integer.valueOf(97),d1.get(n("a")));
assertEquals(Integer.valueOf(98),d1.get(n("b")));
assertEquals(Integer.valueOf(99),d1.get(n("c")));
assertEquals(Integer.valueOf(100),d1.get(n("d")));
assertEquals(Integer.valueOf(101),d1.get(n("e")));
assertEquals(Integer.valueOf(102),d1.get(n("f")));
assertEquals(Integer.valueOf(103),d1.get(n("g")));
}
public void test090() {
assertException(UnsupportedOperationException.class, () -> d1.entrySet().add(e(n("hello"),"bye")));
}
/*
* Test 1XX:
* Testing the iterator, without remove, or (before test180) fail-fast semantics.
* Tests containsKey/contains which if not implemented uses iterator
* but if implemented should do the correct thing.
*/
public void test100() {
it = d1.entrySet().iterator();
assertFalse(it.hasNext());
}
public void test101() {
d1.put(n("one hundred one"),101);
it = d1.entrySet().iterator();
assertTrue(it.hasNext());
}
public void test102() {
d1.put(n("one hundred two"),102);
it = d1.entrySet().iterator();
assertEquals(e(n("one hundred two"),102),it.next());
}
public void test103() {
d1.put(n("one hundred three"),103);
it = d1.entrySet().iterator();
it.next();
assertFalse(it.hasNext());
}
public void test104() {
d1.put(n("one hundred four"),104);
it = d1.entrySet().iterator();
it.next();
assertEquals(Integer.valueOf(104),d1.get(n("one hundred four")));
}
public void test105() {
d1.put(n("one hundred five"),105);
it = d1.entrySet().iterator();
e = it.next();
assertEquals(n("one hundred five"),e.getKey());
assertEquals(Integer.valueOf(105),e.getValue());
}
public void test106() {
d1.put(n("one hundred six"),106);
it = d1.entrySet().iterator();
e = it.next();
e.setValue(16);
assertEquals(Integer.valueOf(16),d1.get(n("one hundred six")));
}
public void test107() {
d1.put(n("one hundred seven"),107);
it = d1.entrySet().iterator();
e = it.next();
e.setValue("107");
assertFalse(it.hasNext());
}
public void test108() {
d1.put(n("one hundred eight"),108);
d1.put(n("one hundred eight"),"108");
it = d1.entrySet().iterator();
assertTrue(it.hasNext());
assertEquals("108",it.next().getValue());
}
public void test109() {
d1.put(n("one hundred nine"),109);
d1.put(n("one hundred nine"),"109");
it = d1.entrySet().iterator();
e = it.next();
it2 = d1.entrySet().iterator();
e.setValue(109); // structure not changed. iterator not stale
assertEquals(109,it2.next().getValue());
assertFalse(it.hasNext());
assertFalse(it2.hasNext());
}
public void test110() {
d1.put(n("one hundred ten"),110);
d1.put(n("sixty"),60);
it = d1.entrySet().iterator();
assertTrue(it.hasNext());
assertEquals(e(n("one hundred ten"),110),it.next());
}
public void test111() {
d1.put(n("one hundred eleven"),111);
d1.put(n("sixty one"),61);
it = d1.entrySet().iterator();
it.next();
assertTrue(it.hasNext());
assertEquals(e(n("sixty one"),61),it.next());
assertFalse(it.hasNext());
}
public void test112() {
d1.put(n("sixty two"),62);
d1.put(n("one hundred twelve"),112);
it = d1.entrySet().iterator();
assertEquals(e(n("sixty two"),62),it.next());
assertEquals(e(n("one hundred twelve"),112),it.next());
}
public void test113() {
d1.put(n("sixty three"),63);
d1.put(n("one hundred thirteen"),113);
it = d1.entrySet().iterator();
assertEquals(e(n("one hundred thirteen"),113),it.next());
it2 = d1.entrySet().iterator();
assertEquals(e(n("sixty three"),63),it.next());
assertEquals(e(n("one hundred thirteen"),113),it2.next());
}
public void test114() {
d1.put(n("one hundred fourteen"),114);
d1.put(n("sixty four"),64);
it = d1.entrySet().iterator();
it.next();
d1.put(n("sixty four"),"64"); // doesn't change structure
assertTrue(it.hasNext());
assertEquals(e(n("sixty four"),"64"),it.next());
assertFalse(it.hasNext());
}
public void test120() {
d1.put(n("seventy"),70);
d1.put(n("zero"),0);
d1.put(n("one hundred twenty"),120);
it = d1.entrySet().iterator();
assertTrue(it.hasNext());
assertEquals(0,it.next().getValue());
assertTrue(it.hasNext());
assertEquals(70,it.next().getValue());
assertTrue(it.hasNext());
assertEquals(120,it.next().getValue());
assertFalse(it.hasNext());
}
public void test121() {
d1.put(n("one hundred twenty-one"),121);
d1.put(n("zero"),0);
d1.put(n("seventy-one"),71);
it = d1.entrySet().iterator();
assertTrue(it.hasNext());
assertEquals(0,it.next().getValue());
assertTrue(it.hasNext());
assertEquals(71,it.next().getValue());
assertTrue(it.hasNext());
assertEquals(121,it.next().getValue());
assertFalse(it.hasNext());
}
public void test122() {
d1.put(n("one hundred twenty-two"),122);
d1.put(n("seventy-two"),72);
d1.put(n("two"),2);
it = d1.entrySet().iterator();
assertTrue(it.hasNext());
assertEquals(72,it.next().getValue());
assertTrue(it.hasNext());
assertEquals(122,it.next().getValue());
assertTrue(it.hasNext());
assertEquals(2,it.next().getValue());
assertFalse(it.hasNext());
}
public void test123() {
d1.put(n("three"),3);
d1.put(n("one hundred twenty-three"),123);
d1.put(n("seventy-three"),73);
it = d1.entrySet().iterator();
assertTrue(it.hasNext());
assertEquals(73,it.next().getValue());
assertTrue(it.hasNext());
assertEquals(3,it.next().getValue());
assertTrue(it.hasNext());
assertEquals(123,it.next().getValue());
assertFalse(it.hasNext());
}
public void test124() {
d1.put(n("twenty-four"),24);
d1.put(n("one hundred twenty-four"),124);
d1.put(n("four"),4);
it = d1.entrySet().iterator();
assertTrue(it.hasNext());
assertEquals(24,it.next().getValue());
assertTrue(it.hasNext());
assertEquals(124,it.next().getValue());
assertTrue(it.hasNext());
assertEquals(4,it.next().getValue());
assertFalse(it.hasNext());
}
public void test125() {
d1.put(n("one hundred twenty-five"),125);
d1.put(n("twenty-five"),25);
d1.put(n("five"),5);
d1.put(n("one hundred twenty-five"),"125");
d1.put(n("twenty-five"),"25");
d1.put(n("five"),"5");
it = d1.entrySet().iterator();
assertTrue(it.hasNext());
assertEquals("125",it.next().getValue());
assertTrue(it.hasNext());
assertEquals("5",it.next().getValue());
assertTrue(it.hasNext());
assertEquals("25",it.next().getValue());
assertFalse(it.hasNext());
}
public void test126() {
d1.put(n("one hundred twenty-six"),126);
d1.put(n("twenty-six"),26);
d1.put(n("seventy-six"),76);
d1.put(n("six"),6);
it = d1.entrySet().iterator();
assertEquals(126,it.next().getValue());
assertEquals(6,it.next().getValue());
assertEquals(26,it.next().getValue());
assertEquals(76,it.next().getValue());
}
public void test127() {
d1.put(n("127"),"one hundred twenty-seven");
d1.put(n("27"),"twenty-seven");
d1.put(n("77"),"seventy-seven");
d1.put(n("7"),"seven");
d1.put(n("1"),"one");
it = d1.entrySet().iterator();
assertEquals("77",it.next().getKey().rep);
assertEquals("1",it.next().getKey().rep);
assertEquals("27",it.next().getKey().rep);
assertEquals("127",it.next().getKey().rep);
assertEquals("7",it.next().getKey().rep);
}
public void test128() {
d1.put(n("128"),"one hundred twenty-eight");
d1.put(n("028"),"twenty-eight");
d1.put(n("078"),"seventy-eight");
d1.put(n("008"),"eight");
d1.put(n("001"),"one");
d1.put(n("280"),"two hundren eighty");
Iterator it = d1.keySet().iterator();
assertEquals("280",it.next().rep);
assertEquals("078",it.next().rep);
assertEquals("001",it.next().rep);
assertEquals("028",it.next().rep);
assertEquals("128",it.next().rep);
assertEquals("008",it.next().rep);
}
public void test129() {
Collection v = d1.values();
d1.put(n("one hundred twenty-nine"),129);
d1.put(n("twenty-nine"),29);
d1.put(n("seventy-nine"),79);
d1.put(n("nine"),9);
d1.put(n("eight"),8);
d1.put(n("twelve"),12);
d1.put(n("one"),1);
Iterator it = v.iterator();
assertEquals(129,it.next());
assertEquals(1,it.next());
assertEquals(79,it.next());
assertEquals(29,it.next());
assertEquals(8,it.next());
assertEquals(9,it.next());
assertEquals(12,it.next());
assertFalse(it.hasNext());
}
private void makeTree() {
// (((1)2(((3(4))5)6((7(8))9)))10((11)12(13)))
d1.put(n(100),"100");
d1.put(n(20),"20");
d1.put(n(10),"10");
d1.put(n(60),"60");
d1.put(n(50),"50");
d1.put(n(30),"30");
d1.put(n(40),"40");
d1.put(n(90), "90");
d1.put(n(70), "70");
d1.put(n(80),"80");
d1.put(n(120),"120");
d1.put(n(110),"110");
d1.put(n(130),"130");
}
public void test130() {
Set s = d1.keySet();
makeTree();
Iterator it = s.iterator();
assertEquals(n(90),it.next());
assertEquals(n(80),it.next());
assertEquals(n(70),it.next());
assertEquals(n(60),it.next());
assertEquals(n(50),it.next());
assertEquals(n(40),it.next());
assertEquals(n(30),it.next());
assertEquals(n(20),it.next());
assertEquals(n(10),it.next());
assertEquals(n(120),it.next());
assertEquals(n(100),it.next());
assertEquals(n(110),it.next());
assertEquals(n(130),it.next());
}
public void test140() {
makeTree();
assertTrue(d1.containsKey(n(10)));
assertTrue(d1.containsKey(n(20)));
assertTrue(d1.containsKey(n(30)));
assertTrue(d1.containsKey(n(40)));
assertTrue(d1.containsKey(n(50)));
assertTrue(d1.containsKey(n(60)));
assertTrue(d1.containsKey(n(70)));
assertTrue(d1.containsKey(n(80)));
assertTrue(d1.containsKey(n(90)));
assertTrue(d1.containsKey(n(100)));
assertTrue(d1.containsKey(n(110)));
assertTrue(d1.containsKey(n(120)));
assertTrue(d1.containsKey(n(130)));
}
public void test145() {
makeTree();
assertFalse(d1.containsKey(n(0)));
assertFalse(d1.containsKey(n(15)));
assertFalse(d1.containsKey(n(25)));
assertFalse(d1.containsKey(n(35)));
assertFalse(d1.containsKey(n(45)));
assertFalse(d1.containsKey(n(55)));
assertFalse(d1.containsKey(n(65)));
assertFalse(d1.containsKey(n(75)));
assertFalse(d1.containsKey(n(85)));
assertFalse(d1.containsKey(n(95)));
assertFalse(d1.containsKey(n(105)));
assertFalse(d1.containsKey(n(115)));
assertFalse(d1.containsKey(n(125)));
assertFalse(d1.containsKey(n(135)));
assertFalse(d1.containsKey(n(140)));
}
public void test149() {
makeTree();
assertFalse(d1.containsKey("10"));
assertFalse(d1.containsKey(null));
assertFalse(d1.containsKey(new Object()));
}
public void test150() {
d1.put(n("one hundred fifty"), 150);
assertTrue(d1.entrySet().contains(e(n("one hundred fifty"),150)));
}
public void test151() {
d1.put(n("one hundred fifty-one"),151);
assertFalse(d1.entrySet().contains(e(n("one hundred fifty-one"),150)));
}
public void test152() {
d1.put(n("one hundred fifty-two"),152);
assertFalse(d1.entrySet().contains(e(n("one hundred fifty-two"),null)));
}
public void test153() {
d1.put(n("one hundred fifty-three"),null);
assertTrue(d1.entrySet().contains(e(n("one hundred fifty-three"),null)));
}
public void test154() {
d1.put(n("one hundred fifty-four"),null);
assertFalse(d1.entrySet().contains(e(n("one hundred fifty-four"),154)));
}
public void test155() {
d1.put(n("one hundred fifty-five"),155);
assertFalse(d1.entrySet().contains(e("/one hundred fifty-five",155)));
}
public void test156() {
d1.put(n("one hundred fifty-six"),156);
assertFalse(d1.entrySet().contains(e((Name)null,156)));
}
public void test157() {
d1.put(n("one hundred fifty-seven"),157);
assertFalse(d1.entrySet().contains("/one hundred fifty-seven=157"));
}
public void test158() {
d1.put(n("one hundred fifty-eight"),158);
assertFalse(d1.entrySet().contains(158));
}
public void test159() {
d1.put(n("one hundred fifty-nine"),159);
assertFalse(d1.entrySet().contains(null));
}
public void test160() {
Set> s = d1.entrySet();
makeTree();
assertTrue(s.contains(e(n(10),"10")));
assertTrue(s.contains(e(n(20),"20")));
assertTrue(s.contains(e(n(30),"30")));
assertTrue(s.contains(e(n(40),"40")));
assertTrue(s.contains(e(n(50),"50")));
assertTrue(s.contains(e(n(60),"60")));
assertTrue(s.contains(e(n(70),"70")));
assertTrue(s.contains(e(n(80),"80")));
assertTrue(s.contains(e(n(90),"90")));
assertTrue(s.contains(e(n(100),"100")));
assertTrue(s.contains(e(n(110),"110")));
assertTrue(s.contains(e(n(120),"120")));
assertTrue(s.contains(e(n(130),"130")));
}
public void test170() {
makeTree();
Set> s = d1.entrySet();
assertFalse(s.contains(e(n(10),"1")));
assertFalse(s.contains(e(n(20),"2")));
assertFalse(s.contains(e(n(30),"3")));
assertFalse(s.contains(e(n(40),"4")));
assertFalse(s.contains(e(n(50),"5")));
assertFalse(s.contains(e(n(60),"6")));
assertFalse(s.contains(e(n(70),"7")));
assertFalse(s.contains(e(n(80),"8")));
assertFalse(s.contains(e(n(90),"9")));
assertFalse(s.contains(e(n(100),"10")));
assertFalse(s.contains(e(n(110),"11")));
assertFalse(s.contains(e(n(120),"12")));
assertFalse(s.contains(e(n(130),"13")));
}
public void test179() {
makeTree();
assertEquals(13,d1.size());
assertNull(d1.get(0));
for (int i=10; i <= 130; i+=10)
assertEquals(""+i,d1.get(n(i)));
for (int i=5; i < 130; i+=10)
assertNull(d1.get(i));
assertNull(d1.get(14));
testCollection(d1.keySet(),"BIG",n(90),n(80),n(70),n(60),n(50),n(40),n(30),n(20),n(10),n(120),n(100),n(110),n(130));
for (int i=10; i <= 130; i += 20)
d1.put(n(i), "-"+i);
assertEquals(13,d1.size());
for (int i=10; i <= 130; i += 10) {
String expected = (((i/10)&1) == 0 ? "" : "-") + i;
assertEquals(expected,d1.get(n(i)));
}
testCollection(d1.keySet(),"BIG-",n(90),n(80),n(70),n(60),n(50),n(40),n(30),n(20),n(10),n(120),n(100),n(110),n(130));
}
/*
* Fail fast semantics (without remove) testing starts here.
*/
public void test180() {
it = d1.entrySet().iterator();
d1.put(n("180"), 180);
assertException(ConcurrentModificationException.class,() -> it.hasNext());
}
public void test181() {
it = d1.entrySet().iterator();
d1.put(n("181"), 181);
assertException(ConcurrentModificationException.class,() -> it.next());
}
public void test182() {
d1.put(n("182"),182);
it = d1.entrySet().iterator();
assertTrue(it.hasNext());
d1.put(n("0"),0);
assertException(ConcurrentModificationException.class,() -> it.hasNext());
}
public void test183() {
d1.put(n("183"),183);
d1.put(n("0"),0);
it = d1.entrySet().iterator();
d1.put(n("200"),200);
assertException(ConcurrentModificationException.class,() -> it.hasNext());
}
public void test184() {
d1.put(n("184"),184);
it = d1.entrySet().iterator();
d1.put(n("0"),0);
it2 = d1.entrySet().iterator();
assertTrue(it2.hasNext());
assertEquals(0,it2.next().getValue());
d1.put(n("200"),200);
assertException(ConcurrentModificationException.class,() -> it2.next());
}
public void test190() {
makeTree();
it = d1.entrySet().iterator();
it.next();
it.next();
it.next();
d1.put(n(0),"0");
assertException(ConcurrentModificationException.class,() -> it.hasNext());
}
/**
* test2XX test remove in the main class, clear in the main class,
* and clear in the entry set class.
*/
public void test200() {
assertNull(d1.remove(n("hello")));
}
public void test201() {
assertNull(d1.remove("bye"));
}
public void test202() {
assertNull(d1.remove(new Object()));
}
public void test203() {
assertNull(d1.remove(null));
}
public void test210() {
d1.put(n("apples"),10);
assertEquals(10,d1.remove(n("apples")));
}
public void test211() {
d1.put(n("bread"),2);
assertNull(d1.remove("/bread"));
}
public void test212() {
d1.put(n("carrots"),12);
assertNull(d1.remove("carrots"));
}
public void test213() {
d1.put(n("donuts"),0);
assertNull(d1.remove(n("apples")));
assertNull(d1.remove(n("eggs")));
}
public void test214() {
d1.put(n("eggs"),12);
d1.remove(n("eggs"));
assertEquals(0,d1.size());
}
public void test215() {
d1.put(n("fish"),1);
d1.remove("fish");
assertNull(d1.get("fish"));
}
public void test216() {
d1.put(n("grapes"),"1 lb.");
d1.remove(n("hummus"));
assertEquals(1,d1.size());
}
public void test217() {
d1.put(n("ice-cream"),"1 pint");
Set> s = d1.entrySet();
d1.remove(n("ice-cream"));
assertEquals(0,s.size());
}
public void test220() {
d1.put(n(220),"220");
d1.put(n(22),"22");
assertEquals("22",d1.remove(n(22)));
}
public void test221() {
d1.put(n(221), "221");
d1.put(n(21), "21");
d1.remove(n(21));
assertEquals(1,d1.size());
}
public void test222() {
d1.put(n(222),"222");
d1.put(n(22), "22");
d1.remove(n(22));
assertEquals("222",d1.get(n(222)));
}
public void test223() {
d1.put(n(223),"223");
d1.put(n(23),"23");
assertEquals("223",d1.remove(n(223)));
}
public void test224() {
d1.put(n(224),"224");
d1.put(n(24),"24");
d1.remove(n(224));
assertEquals(1,d1.size());
}
public void test225() {
d1.put(n(225),"225");
d1.put(n(25),"25");
d1.remove(n(225));
assertEquals("25",d1.get(n(25)));
}
public void test226() {
d1.put(n(226),"226");
d1.put(n(622),"622");
assertEquals("622",d1.remove(n(622)));
assertEquals(1,d1.size());
assertEquals("226",d1.get(n(226)));
}
public void test227() {
d1.put(n(227),"227");
d1.put(n(722), "722");
assertEquals("227",d1.remove(n(227)));
assertEquals(1,d1.size());
assertEquals("722",d1.get(n(722)));
}
public void test228() {
d1.put(n("a"), 2);
d1.put(n("A"), 28);
d1.remove(n("a"));
assertEquals(1, d1.size());
d1.put(n("A"), 228); // should change previous entry
assertEquals(1, d1.size());
assertEquals(228, d1.get(n("A")));
}
public void test230() {
d1.put(n("apples"),5);
d1.put(n("bread"),1);
d1.put(n("carrots"),8);
assertEquals(5,d1.remove(n("apples")));
assertEquals(2,d1.size());
assertEquals(null,d1.get(n("apples")));
assertEquals(1,d1.get(n("bread")));
assertEquals(8,d1.get(n("carrots")));
}
public void test231() {
d1.put(n("apples"),5);
d1.put(n("bread"),1);
d1.put(n("carrots"),8);
assertEquals(1,d1.remove(n("bread")));
assertEquals(2,d1.size());
assertEquals(5,d1.get(n("apples")));
assertEquals(null,d1.get(n("bread")));
assertEquals(8,d1.get(n("carrots")));
}
public void test232() {
d1.put(n("apples"),5);
d1.put(n("bread"),1);
d1.put(n("carrots"),8);
assertEquals(8,d1.remove(n("carrots")));
assertEquals(2,d1.size());
assertEquals(5,d1.get(n("apples")));
assertEquals(1,d1.get(n("bread")));
assertEquals(null,d1.get(n("carrots")));
}
public void test234() {
d1.put(n("donuts"),0);
d1.put(n("fish"),1);
d1.put(n("eggs"),12);
assertEquals(0,d1.remove(n("donuts")));
assertEquals(2,d1.size());
assertEquals(null,d1.remove(n("donuts")));
assertEquals(12,d1.remove(n("eggs")));
assertEquals(1,d1.remove(n("fish")));
}
public void test235() {
d1.put(n("donuts"),0);
d1.put(n("fish"),1);
d1.put(n("eggs"),12);
assertEquals(12,d1.remove(n("eggs")));
assertEquals(2,d1.size());
assertEquals(0,d1.remove(n("donuts")));
assertEquals(null,d1.remove(n("eggs")));
assertEquals(1,d1.remove(n("fish")));
}
public void test236() {
d1.put(n("donuts"),0);
d1.put(n("fish"),1);
d1.put(n("eggs"),12);
assertEquals(1,d1.remove(n("fish")));
assertEquals(2,d1.size());
assertEquals(0,d1.remove(n("donuts")));
assertEquals(12,d1.remove(n("eggs")));
assertEquals(null,d1.remove(n("fish")));
}
public void test237() {
d1.put(n("lemons"),"3");
d1.put(n("milk"),"1 gal");
d1.put(n("grapes"),"1 lb");
assertEquals("1 lb",d1.remove(n("grapes")));
assertEquals(2,d1.size());
assertEquals(null,d1.get(n("grapes")));
assertEquals("3",d1.get(n("lemons")));
assertEquals("1 gal",d1.get(n("milk")));
}
public void test238() {
d1.put(n("lemons"),"3");
d1.put(n("milk"),"1 gal");
d1.put(n("grapes"),"1 lb");
assertEquals("1 gal",d1.remove(n("milk")));
assertEquals(2,d1.size());
assertEquals("1 lb",d1.get(n("grapes")));
assertEquals("3",d1.get(n("lemons")));
assertEquals(null,d1.get(n("milk")));
}
public void test239() {
d1.put(n("lemons"),"3");
d1.put(n("milk"),"1 gal");
d1.put(n("grapes"),"1 lb");
assertEquals("3",d1.remove(n("lemons")));
assertEquals(2,d1.size());
assertEquals("1 lb",d1.get(n("grapes")));
assertEquals(null,d1.get(n("lemons")));
assertEquals("1 gal",d1.get(n("milk")));
}
public void test240() {
makeTree();
assertEquals("10",d1.remove(n(10)));
assertEquals(null,d1.get(n(10)));
assertEquals("20",d1.get(n(20)));
assertEquals("30",d1.get(n(30)));
assertEquals("40",d1.get(n(40)));
assertEquals("50",d1.get(n(50)));
assertEquals("60",d1.get(n(60)));
assertEquals("70",d1.get(n(70)));
assertEquals("80",d1.get(n(80)));
assertEquals("90",d1.get(n(90)));
assertEquals("100",d1.get(n(100)));
assertEquals("110",d1.get(n(110)));
assertEquals("120",d1.get(n(120)));
assertEquals("130",d1.get(n(130)));
}
public void test241() {
makeTree();
assertEquals("20",d1.remove(n(20)));
assertEquals("10",d1.get(n(10)));
assertEquals(null,d1.get(n(20)));
assertEquals("30",d1.get(n(30)));
assertEquals("40",d1.get(n(40)));
assertEquals("50",d1.get(n(50)));
assertEquals("60",d1.get(n(60)));
assertEquals("70",d1.get(n(70)));
assertEquals("80",d1.get(n(80)));
assertEquals("90",d1.get(n(90)));
assertEquals("100",d1.get(n(100)));
assertEquals("110",d1.get(n(110)));
assertEquals("120",d1.get(n(120)));
assertEquals("130",d1.get(n(130)));
}
public void test242() {
makeTree();
assertEquals("30",d1.remove(n(30)));
assertEquals("10",d1.get(n(10)));
assertEquals("20",d1.get(n(20)));
assertEquals(null,d1.get(n(30)));
assertEquals("40",d1.get(n(40)));
assertEquals("50",d1.get(n(50)));
assertEquals("60",d1.get(n(60)));
assertEquals("70",d1.get(n(70)));
assertEquals("80",d1.get(n(80)));
assertEquals("90",d1.get(n(90)));
assertEquals("100",d1.get(n(100)));
assertEquals("110",d1.get(n(110)));
assertEquals("120",d1.get(n(120)));
assertEquals("130",d1.get(n(130)));
}
public void test243() {
makeTree();
assertEquals("40",d1.remove(n(40)));
assertEquals("10",d1.get(n(10)));
assertEquals("20",d1.get(n(20)));
assertEquals("30",d1.get(n(30)));
assertEquals(null,d1.get(n(40)));
assertEquals("50",d1.get(n(50)));
assertEquals("60",d1.get(n(60)));
assertEquals("70",d1.get(n(70)));
assertEquals("80",d1.get(n(80)));
assertEquals("90",d1.get(n(90)));
assertEquals("100",d1.get(n(100)));
assertEquals("110",d1.get(n(110)));
assertEquals("120",d1.get(n(120)));
assertEquals("130",d1.get(n(130)));
}
public void test244() {
makeTree();
assertEquals("50",d1.remove(n(50)));
assertEquals("10",d1.get(n(10)));
assertEquals("20",d1.get(n(20)));
assertEquals("30",d1.get(n(30)));
assertEquals("40",d1.get(n(40)));
assertEquals(null,d1.get(n(50)));
assertEquals("60",d1.get(n(60)));
assertEquals("70",d1.get(n(70)));
assertEquals("80",d1.get(n(80)));
assertEquals("90",d1.get(n(90)));
assertEquals("100",d1.get(n(100)));
assertEquals("110",d1.get(n(110)));
assertEquals("120",d1.get(n(120)));
assertEquals("130",d1.get(n(130)));
}
public void test245() {
makeTree();
assertEquals("60",d1.remove(n(60)));
assertEquals("10",d1.get(n(10)));
assertEquals("20",d1.get(n(20)));
assertEquals("30",d1.get(n(30)));
assertEquals("40",d1.get(n(40)));
assertEquals("50",d1.get(n(50)));
assertEquals(null,d1.get(n(60)));
assertEquals("70",d1.get(n(70)));
assertEquals("80",d1.get(n(80)));
assertEquals("90",d1.get(n(90)));
assertEquals("100",d1.get(n(100)));
assertEquals("110",d1.get(n(110)));
assertEquals("120",d1.get(n(120)));
assertEquals("130",d1.get(n(130)));
}
public void test246() {
makeTree();
assertEquals("70",d1.remove(n(70)));
assertEquals("10",d1.get(n(10)));
assertEquals("20",d1.get(n(20)));
assertEquals("30",d1.get(n(30)));
assertEquals("40",d1.get(n(40)));
assertEquals("50",d1.get(n(50)));
assertEquals("60",d1.get(n(60)));
assertEquals(null,d1.get(n(70)));
assertEquals("80",d1.get(n(80)));
assertEquals("90",d1.get(n(90)));
assertEquals("100",d1.get(n(100)));
assertEquals("110",d1.get(n(110)));
assertEquals("120",d1.get(n(120)));
assertEquals("130",d1.get(n(130)));
}
public void test247() {
makeTree();
assertEquals("80",d1.remove(n(80)));
assertEquals("10",d1.get(n(10)));
assertEquals("20",d1.get(n(20)));
assertEquals("30",d1.get(n(30)));
assertEquals("40",d1.get(n(40)));
assertEquals("50",d1.get(n(50)));
assertEquals("60",d1.get(n(60)));
assertEquals("70",d1.get(n(70)));
assertEquals(null,d1.get(n(80)));
assertEquals("90",d1.get(n(90)));
assertEquals("100",d1.get(n(100)));
assertEquals("110",d1.get(n(110)));
assertEquals("120",d1.get(n(120)));
assertEquals("130",d1.get(n(130)));
}
public void test248() {
makeTree();
assertEquals("90",d1.remove(n(90)));
assertEquals("10",d1.get(n(10)));
assertEquals("20",d1.get(n(20)));
assertEquals("30",d1.get(n(30)));
assertEquals("40",d1.get(n(40)));
assertEquals("50",d1.get(n(50)));
assertEquals("60",d1.get(n(60)));
assertEquals("70",d1.get(n(70)));
assertEquals("80",d1.get(n(80)));
assertEquals(null,d1.get(n(90)));
assertEquals("100",d1.get(n(100)));
assertEquals("110",d1.get(n(110)));
assertEquals("120",d1.get(n(120)));
assertEquals("130",d1.get(n(130)));
}
public void test249() {
makeTree();
assertEquals("100",d1.remove(n(100)));
assertEquals("10",d1.get(n(10)));
assertEquals("20",d1.get(n(20)));
assertEquals("30",d1.get(n(30)));
assertEquals("40",d1.get(n(40)));
assertEquals("50",d1.get(n(50)));
assertEquals("60",d1.get(n(60)));
assertEquals("70",d1.get(n(70)));
assertEquals("80",d1.get(n(80)));
assertEquals("90",d1.get(n(90)));
assertEquals(null,d1.get(n(100)));
assertEquals("110",d1.get(n(110)));
assertEquals("120",d1.get(n(120)));
assertEquals("130",d1.get(n(130)));
}
public void test250() {
d1.clear();
assertEquals(0,d1.size());
}
public void test251() {
d1.put(n("apples"),4);
d1.clear();
assertEquals(0,d1.size());
}
public void test252() {
d1.put(n("bread"),1);
d1.clear();
assertEquals(null,d1.get(n("bread")));
}
public void test253() {
d1.put(n("carrots"),8);
d1.put(n("donuts"),0);
d1.clear();
assertEquals(0,d1.size());
}
public void test254() {
d1.put(n("eggs"),12);
d1.put(n("fish"),1);
d1.put(n("grapes"),100);
d1.clear();
assertEquals(null,d1.get(n("fish")));
}
public void test255() {
d1.put(n("hummus"),"8 oz.");
d1.put(n("ice cream"),"1 qt.");
d1.put(n("juice"),"0.5 gal");
d1.put(n("kale"),"1 bunch");
d1.clear();
assertEquals(0,d1.size());
}
public void test256() {
d1.put(n("oranges"), 6);
d1.put(n("milk"),"1 gal.");
d1.put(n("lemons"), 5);
d1.put(n("nuts"),"12 oz.");
d1.put(n("parsley"),"1 bunch");
d1.put(n("quinoa"),"1 lb.");
d1.clear();
assertEquals(null,d1.get(n("oranges")));
}
public void test257() {
makeTree();
d1.clear();
for (int i=1; i <= 13; ++i) {
assertNull(d1.get(n(i*10)));
}
}
public void test258() {
makeTree();
d1.clear();
makeTree();
for (int i=1; i <= 13; ++i) {
assertEquals(""+(i*10),d1.get(n(i*10)));
}
}
public void test259() {
it = d1.entrySet().iterator();
d1.clear(); // nothing to clear: so, shouldn't disturb iterator
assertFalse(it.hasNext());
}
public void test260() {
d1.entrySet().clear();
assertEquals(0,d1.size());
}
public void test261() {
d1.put(n("WI"),"Madison");
d1.entrySet().clear();
assertEquals(0,d1.size());
}
public void test262() {
Set> s = d1.entrySet();
d1.put(n("IL"),"Springfield");
s.clear();
assertEquals(0,d1.size());
}
public void test263() {
d1.put(n("CA"),"Sacramento");
d1.put(n("NV"),"Carson City");
d1.entrySet().clear();
assertEquals(0,d1.size());
}
public void test264() {
d1.put(n("MT"),"Helena");
d1.put(n("ND"),"Bismarck");
d1.put(n("MN"),"Minneapolis");
d1.entrySet().clear();
assertEquals(0,d1.size());
}
public void test265() {
d1.put(n("ME"),"Augusta");
d1.put(n("VT"),"Montpelier");
d1.put(n("NH"),"Concord");
d1.put(n("MA"),"Boston");
d1.put(n("RI"),"Providence");
d1.put(n("CT"),"Hartford");
d1.entrySet().clear();
assertEquals(0,d1.size());
assertEquals(null,d1.get(n("Augusta")));
}
public void test266() {
makeTree();
d1.entrySet().clear();
assertEquals(0,d1.size());
}
public void test269() {
it = d1.entrySet().iterator();
d1.entrySet().clear(); // nothing to remove
assertFalse(it.hasNext());
}
public void test270() {
d1.put(n(1), 1);
d1.put(n(2), 2);
d1.put(n(3), 3);
d1.put(n(4), 4);
d1.remove(n(4));
d1.remove(n(3));
d1.remove(n(2));
d1.put(n("a"), "a");
d1.put(n("A"), "A");
d1.put(n("I"), "I");
it = d1.entrySet().iterator();
assertEquals(Integer.valueOf(1), it.next().getValue());
assertEquals("a", it.next().getValue());
assertEquals("A", it.next().getValue());
assertEquals("I", it.next().getValue());
}
public void test290() {
d1.put(n(1), 1);
d1.put(n(2), 2);
d1.put(n(3), 3);
d1.put(n(4), 4);
d1.put(n(5), 5);
d1.remove(n(5));
d1.remove(n(4));
d1.remove(n(3));
d1.remove(n(2));
d1.remove(n(1));
assertEquals(".-----..", ((Dictionary)d1).toDebugString());
d1.put(n(0), 0);
assertEquals(1, d1.size());
}
/*
* test3XX: tests of remove using iterators
* (Errors starting 350)
*/
public void test300() {
d1.put(n(300),300);
it = d1.entrySet().iterator();
it.next();
it.remove();
assertEquals(0,d1.size());
}
public void test301() {
d1.put(n(301),301);
it = d1.entrySet().iterator();
it.next();
it.remove();
assertFalse(it.hasNext());
}
public void test302() {
d1.put(n(302),302);
it = d1.entrySet().iterator();
it.next();
it.remove();
assertNull(d1.get(n(302)));
}
public void test303() {
d1.put(n(303),303);
it = d1.entrySet().iterator();
it.next();
it.remove();
it = d1.entrySet().iterator();
assertFalse(it.hasNext());
}
public void test310() {
d1.put(n(310),310);
d1.put(n(31),31);
it = d1.entrySet().iterator();
it.next();
it.remove();
assertEquals(1,d1.size());
}
public void test311() {
d1.put(n(311),311);
d1.put(n(31),31);
it = d1.entrySet().iterator();
it.next();
it.remove();
assertTrue(it.hasNext());
}
public void test312() {
d1.put(n(312),312);
d1.put(n(31),31);
it = d1.entrySet().iterator();
it.next();
it.remove();
assertEquals(null,d1.get(n(312)));
}
public void test313() {
d1.put(n(313),313);
d1.put(n(31),31);
it = d1.entrySet().iterator();
it.next();
it.remove();
assertEquals(e(n(31),31),it.next());
}
public void test314() {
d1.put(n(314),314);
d1.put(n(31),31);
it = d1.entrySet().iterator();
it.next();
it.next();
it.remove();
assertEquals(1,d1.size());
}
public void test315() {
d1.put(n(315),315);
d1.put(n(31),31);
it = d1.entrySet().iterator();
it.next();
it.next();
it.remove();
assertFalse(it.hasNext());
}
public void test316() {
d1.put(n(316),316);
d1.put(n(31),31);
it = d1.entrySet().iterator();
it.next();
it.next();
it.remove();
assertEquals(316,d1.get(n(316)));
}
public void test317() {
d1.put(n(31),31);
d1.put(n(317),317);
it = d1.entrySet().iterator();
it.next();
it.remove();
assertEquals(1,d1.size());
}
public void test318() {
d1.put(n(31),31);
d1.put(n(318),318);
it = d1.entrySet().iterator();
it.next();
it.remove();
assertTrue(it.hasNext());
assertEquals(e(n(31),31),it.next());
assertEquals(31,d1.get(n(31)));
}
public void test319() {
d1.put(n(31),31);
d1.put(n(319),319);
it = d1.entrySet().iterator();
it.next();
it.next();
it.remove();
assertFalse(it.hasNext());
assertEquals(1,d1.size());
assertEquals(319,d1.get(n(319)));
}
public void test320() {
d1.put(n(203), 203);
d1.put(n(320), 320);
d1.put(n(32),32);
it = d1.entrySet().iterator();
it.next();
it.remove();
assertEquals(2,d1.size());
assertTrue(it.hasNext());
assertEquals(e(n(203),203),it.next());
assertEquals(e(n(32),32),it.next());
}
public void test321() {
d1.put(n(213),213);
d1.put(n(321),321);
d1.put(n(32),32);
it = d1.entrySet().iterator();
it.next();
it.next();
it.remove();
assertEquals(2,d1.size());
assertTrue(it.hasNext());
assertEquals(e(n(32),32),it.next());
assertEquals(321,d1.get(n(321)));
}
public void test322() {
d1.put(n(213),213);
d1.put(n(321),321);
d1.put(n(32),32);
it = d1.entrySet().iterator();
it.next();
it.next();
it.next();
it.remove();
assertEquals(2,d1.size());
assertFalse(it.hasNext());
assertEquals(321,d1.get(n(321)));
assertEquals(213,d1.get(n(213)));
}
public void test323() {
d1.put(n(323),323);
d1.put(n(23),23);
d1.put(n(233),233);
it = d1.entrySet().iterator();
it.next();
it.remove();
assertEquals(2,d1.size());
assertTrue(it.hasNext());
assertEquals(e(n(233),233),it.next());
assertEquals(e(n(323),323),it.next());
}
public void test324() {
d1.put(n(324),324);
d1.put(n(32),32);
d1.put(n(243),243);
it = d1.entrySet().iterator();
it.next();
it.next();
it.remove();
assertEquals(2,d1.size());
assertTrue(it.hasNext());
assertEquals(e(n(32),32),it.next());
assertFalse(it.hasNext());
assertEquals(243,d1.get(n(243)));
}
public void test325() {
d1.put(n(325),325);
d1.put(n(32),32);
d1.put(n(253),253);
it = d1.entrySet().iterator();
it.next();
it.next();
it.next();
it.remove();
assertEquals(2,d1.size());
assertFalse(it.hasNext());
assertEquals(325,d1.get(n(325)));
assertEquals(253,d1.get(n(253)));
}
public void test326() {
d1.put(n(32),32);
d1.put(n(263),263);
d1.put(n(326),326);
it = d1.entrySet().iterator();
it.next();
it.remove();
assertEquals(2,d1.size());
assertTrue(it.hasNext());
assertEquals(e(n(326),326),it.next());
assertEquals(e(n(32),32),it.next());
}
public void test327() {
d1.put(n(32),32);
d1.put(n(273),273);
d1.put(n(327),327);
it = d1.entrySet().iterator();
it.next();
it.next();
it.remove();
assertEquals(2,d1.size());
assertTrue(it.hasNext());
assertEquals(e(n(32),32),it.next());
assertEquals(327,d1.get(n(327)));
}
public void test328() {
d1.put(n(32),32);
d1.put(n(283),283);
d1.put(n(328),328);
it = d1.entrySet().iterator();
it.next();
it.next();
it.next();
it.remove();
assertEquals(2,d1.size());
assertFalse(it.hasNext());
assertEquals(328,d1.get(n(328)));
assertEquals(283,d1.get(n(283)));
}
public void test329() {
d1.put(n(329),329);
d1.put(n(293),293);
d1.put(n(32),32);
it = d1.entrySet().iterator();
it.next();
it.remove();
assertEquals(2,d1.size());
assertEquals(e(n(293),293),it.next());
assertEquals(e(n(32),32),it.next());
it.remove();
assertEquals(1,d1.size());
assertEquals(293,d1.get(n(293)));
assertFalse(it.hasNext());
}
public void test330() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next(); it.next();
it.remove();
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 60) assertNull(d1.get(n(60)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test331() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next(); it.next();
it.next();
it.remove();
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 50) assertNull(d1.get(n(50)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test332() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next(); it.next();
it.next(); it.next();
it.remove();
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 40) assertNull(d1.get(n(40)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test333() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next(); it.next();
it.next(); it.next(); it.next();
it.remove();
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 30) assertNull(d1.get(n(30)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test334() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next(); it.next();
it.next(); it.next(); it.next(); it.next();
it.remove();
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 20) assertNull(d1.get(n(20)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test335() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next(); it.next();
it.next(); it.next(); it.next(); it.next();
it.next();
it.remove();
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 10) assertNull(d1.get(n(10)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test336() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next(); it.next();
it.next(); it.next(); it.next(); it.next();
it.next(); it.next();
it.remove();
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 120) assertNull(d1.get(n(120)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test337() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next(); it.next();
it.next(); it.next(); it.next(); it.next();
it.next(); it.next(); it.next();
it.remove();
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 100) assertNull(d1.get(n(100)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test338() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next(); it.next();
it.next(); it.next(); it.next(); it.next();
it.next(); it.next(); it.next(); it.next();
it.remove();
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 110) assertNull(d1.get(n(110)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test339() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next(); it.next();
it.next(); it.next(); it.next(); it.next();
it.next(); it.next(); it.next(); it.next();
it.next();
it.remove();
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 130) assertNull(d1.get(n(130)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test340() {
makeTree();
it = d1.entrySet().iterator();
it.next();
it.remove(); it.next(); it.next(); it.next(); it.remove();
assertEquals(11,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 90 || i == 60) assertNull("d1.get(n("+i+"))",d1.get(n(i)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test341() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next();
it.remove(); it.next(); it.next(); it.next(); it.remove();
assertEquals(11,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 80 || i == 50) assertNull("d1.get(n("+i+"))",d1.get(n(i)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test342() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next();
it.remove(); it.next(); it.next(); it.next(); it.remove();
assertEquals(11,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 70 || i == 40) assertNull("d1.get(n("+i+"))",d1.get(n(i)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test343() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next(); it.next();
it.remove(); it.next(); it.next(); it.next(); it.remove();
assertEquals(11,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 60 || i == 30) assertNull("d1.get(n("+i+"))",d1.get(n(i)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test344() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next(); it.next();
it.next();
it.remove(); it.next(); it.next(); it.next(); it.remove();
assertEquals(11,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 50 || i == 20) assertNull("d1.get(n("+i+"))",d1.get(n(i)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test345() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next(); it.next();
it.next(); it.next();
it.remove(); it.next(); it.next(); it.next(); it.remove();
assertEquals(11,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 40 || i == 10) assertNull("d1.get(n("+i+"))",d1.get(n(i)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test346() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next(); it.next();
it.next(); it.next(); it.next();
it.remove(); it.next(); it.next(); it.next(); it.remove();
assertEquals(11,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 30 || i == 120) assertNull("d1.get(n("+i+"))",d1.get(n(i)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test347() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next(); it.next();
it.next(); it.next(); it.next(); it.next();
it.remove(); it.next(); it.next(); it.next(); it.remove();
assertEquals(11,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 20 || i == 100) assertNull("d1.get(n("+i+"))",d1.get(n(i)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test348() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next(); it.next();
it.next(); it.next(); it.next(); it.next();
it.next();
it.remove(); it.next(); it.next(); it.next(); it.remove();
assertEquals(11,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 10 || i == 110) assertNull("d1.get(n("+i+"))",d1.get(n(i)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test349() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next(); it.next();
it.next(); it.next(); it.next(); it.next();
it.next(); it.next();
it.remove(); it.next(); it.next(); it.next(); it.remove();
assertEquals(11,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 130 || i == 120) assertNull("d1.get(n("+i+"))",d1.get(n(i)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test350() {
it = d1.entrySet().iterator();
assertException(IllegalStateException.class,() -> it.remove());
}
public void test351() {
d1.put(n("351"),"Data Structures & Algorithms");
it = d1.entrySet().iterator();
assertException(IllegalStateException.class,() -> it.remove());
}
public void test352() {
d1.put(n("352"),"Algorithms & Data Structures");
it = d1.entrySet().iterator();
it.next();
it.remove();
assertException(IllegalStateException.class,() -> it.remove());
}
public void test353() {
d1.put(n("353"),"Algorithms for Data Structures");
d1.put(n("153"),"Ruby on Rails");
it = d1.entrySet().iterator();
it.next();
it.remove();
assertException(IllegalStateException.class,() -> it.remove());
}
public void test360() {
d1.put(n(360),"360");
it = d1.entrySet().iterator();
d1.remove(n(361));
assertTrue(it.hasNext());
}
public void test361() {
d1.put(n(361),"361");
it = d1.entrySet().iterator();
d1.remove(n(361));
assertException(ConcurrentModificationException.class, () -> it.hasNext());
}
public void test362() {
d1.put(n(362),"362");
it = d1.entrySet().iterator();
d1.remove(n(362));
assertException(ConcurrentModificationException.class, () -> it.next());
}
public void test363() {
d1.put(n(363),"363");
it = d1.entrySet().iterator();
it.next();
d1.remove(n(363));
assertException(ConcurrentModificationException.class, () -> it.hasNext());
}
public void test364() {
d1.put(n(364),"364");
it = d1.entrySet().iterator();
it.next();
d1.remove(n(364));
assertException(ConcurrentModificationException.class, () -> it.remove());
}
public void test370() {
d1.put(n(370),"370");
it = d1.entrySet().iterator();
it2 = d1.entrySet().iterator();
assertTrue(it.hasNext());
assertTrue(it2.hasNext());
it2.next();
assertTrue(it.hasNext());
assertFalse(it2.hasNext());
it2.remove();
assertException(ConcurrentModificationException.class, () -> it.hasNext());
assertException(ConcurrentModificationException.class, () -> it.next());
}
public void test375() {
makeTree();
it = d1.entrySet().iterator();
it2 = d1.entrySet().iterator();
it.next(); it.next();
it2.next(); it2.next(); it2.next();
it2.remove();
assertException(ConcurrentModificationException.class, () -> it.hasNext());
assertException(ConcurrentModificationException.class, () -> it.next());
assertException(ConcurrentModificationException.class, () -> it.remove());
}
public void test380() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next();
d1.clear();
assertException(ConcurrentModificationException.class, () -> it.hasNext());
assertException(ConcurrentModificationException.class, () -> it.next());
assertException(ConcurrentModificationException.class, () -> it.remove());
}
public void test382() {
makeTree();
it = d1.entrySet().iterator();
((Dictionary)d1).copy((Dictionary)d1); // should have no effect
assertTrue(it.hasNext());
}
public void test383() {
makeTree();
it = d1.entrySet().iterator();
Dictionary d2 = new Dictionary();
d2.put(n(30), "30");
((Dictionary)d1).copy(d2); // should have no effect
assertTrue(it.hasNext());
}
public void test387() {
makeTree();
for (Iterator it = d1.keySet().iterator(); it.hasNext(); ) {
it.next();
it.remove();
}
assertEquals(0, d1.size()); // nothing but dummies left
it = d1.entrySet().iterator();
d1.clear(); // what does this do? Careful!
assertFalse(it.hasNext());
assertException(IllegalStateException.class, () -> it.remove());
}
public void test390() {
makeTree();
it = d1.entrySet().iterator();
it.next(); it.next(); it.next(); it.next();
d1.entrySet().clear();
assertException(ConcurrentModificationException.class, () -> it.hasNext());
assertException(ConcurrentModificationException.class, () -> it.next());
assertException(ConcurrentModificationException.class, () -> it.remove());
}
public void test399() {
makeTree();
it = d1.entrySet().iterator();
while (it.hasNext()) {
it.next();
it.remove();
}
assertEquals(0,d1.size());
}
/*
* test4XX testing remove on Entry Set
*/
public void test400() {
assertFalse(d1.entrySet().remove(null));
}
public void test401() {
assertFalse(d1.entrySet().remove(n(401)));
}
public void test402() {
assertFalse(d1.entrySet().remove(e("/402","402")));
}
public void test403() {
assertFalse(d1.entrySet().remove(e(n(403),403)));
}
public void test404() {
it = d1.entrySet().iterator();
d1.entrySet().remove(e(n(404),"404"));
assertFalse(it.hasNext());
}
public void test410() {
d1.put(n(410),410);
assertFalse(d1.entrySet().remove(null));
assertEquals(1,d1.size());
}
public void test411() {
d1.put(n(411),411);
assertFalse(d1.entrySet().remove("411"));
}
public void test412() {
d1.put(n(412), 412);
assertFalse(d1.entrySet().remove(n(412)));
assertEquals(1,d1.size());
}
public void test413() {
d1.put(n(413), 413);
assertFalse(d1.entrySet().remove(e("/413",413)));
assertEquals(1,d1.size());
}
public void test414() {
d1.put(n(414), 414);
assertFalse(d1.entrySet().remove(e(n(414),"414")));
assertEquals(1,d1.size());
}
public void test415() {
d1.put(n(415), 415);
assertFalse(d1.entrySet().remove(e(n(415),null)));
assertEquals(1,d1.size());
}
public void test416() {
d1.put(n(416), null);
assertFalse(d1.entrySet().remove(e(n(416),416)));
assertEquals(1,d1.size());
}
public void test417() {
d1.put(n(417), 417);
assertTrue(d1.entrySet().remove(e(n(417),Integer.valueOf(417))));
assertEquals(0,d1.size());
}
public void test418() {
d1.put(n(418),418);
it = d1.entrySet().iterator();
assertFalse(d1.entrySet().remove(e(n(418),"418")));
assertEquals(e(n(418),418),it.next());
}
public void test419() {
d1.put(n(419),"419");
assertTrue(d1.entrySet().remove(e(n(419),new String("419"))));
assertEquals(0,d1.size());
}
public void test420() {
d1.put(n(420), 420);
d1.put(n(42),42);
assertFalse(d1.entrySet().remove(e(n(42),"42")));
assertTrue(d1.entrySet().remove(e(n(420),420)));
assertEquals(1,d1.size());
assertEquals(42,d1.get(n(42)));
}
public void test421() {
d1.put(n(421), "421");
d1.put(n(42), "42");
assertFalse(d1.entrySet().remove(e(n(421),421)));
assertTrue(d1.entrySet().remove(e(n(42),"42")));
assertEquals(1,d1.size());
assertEquals("421",d1.get(n(421)));
}
public void test422() {
d1.put(n(42), 42);
d1.put(n(422), "422");
assertFalse(d1.entrySet().remove(e(n(42),"42")));
assertTrue(d1.entrySet().remove(e(n(422),"422")));
assertEquals(1,d1.size());
assertEquals(42,d1.get(n(42)));
}
public void test423() {
d1.put(n(42),"42");
d1.put(n(423), 423);
assertFalse(d1.entrySet().remove(e(n(42),42)));
assertTrue(d1.entrySet().remove(e(n(423),423)));
assertEquals(1,d1.entrySet().size());
assertEquals("42",d1.get(n(42)));
}
public void test424() {
Set> s = d1.entrySet();
d1.put(n(424),424);
d1.put(n(42),42);
assertTrue(s.remove(e(n(424),424)));
assertEquals(1,d1.size());
}
public void test430() {
makeTree();
d1.entrySet().remove(e(n(10),"10"));
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 10) assertNull(d1.get(n(10)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test431() {
makeTree();
d1.entrySet().remove(e(n(20),"20"));
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 20) assertNull(d1.get(n(20)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test432() {
makeTree();
d1.entrySet().remove(e(n(30),"30"));
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 30) assertNull(d1.get(n(30)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test433() {
makeTree();
d1.entrySet().remove(e(n(40),"40"));
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 40) assertNull(d1.get(n(40)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test434() {
makeTree();
d1.entrySet().remove(e(n(50),"50"));
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 50) assertNull(d1.get(n(50)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test435() {
makeTree();
d1.entrySet().remove(e(n(60),"60"));
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 60) assertNull(d1.get(n(60)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test436() {
makeTree();
d1.entrySet().remove(e(n(70),"70"));
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 70) assertNull(d1.get(n(70)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test437() {
makeTree();
d1.entrySet().remove(e(n(80),"80"));
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 80) assertNull(d1.get(n(80)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test438() {
makeTree();
d1.entrySet().remove(e(n(90),"90"));
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 90) assertNull(d1.get(n(90)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test439() {
makeTree();
d1.entrySet().remove(e(n(100),"100"));
assertEquals(12,d1.size());
for (int i=10; i <=130; i += 10) {
if (i == 100) assertNull(d1.get(n(100)));
else assertEquals("d1.get(n("+i+"))",""+i,d1.get(n(i)));
}
}
public void test440() {
makeTree();
Set> s = d1.entrySet();
for (int i=130; i > 0; i -= 10) {
s.remove(e(n(i),""+i));
}
assertEquals(0,d1.size());
}
public void test445() {
makeTree();
for (Entry e : d1.entrySet()) {
e.setValue(e.getKey());
}
for (int i=10; i <=130; i+= 10) {
assertEquals("d1.get(n("+i+"))",n(i),d1.get(n(i)));
}
}
public void test460() {
d1.put(n(460), 460);
assertException(UnsupportedOperationException.class,() -> d1.entrySet().add(e(n(460), "460")));
}
public void test465() {
d1.put(n(365),"365");
it = d1.entrySet().iterator();
assertFalse(d1.entrySet().remove(e(n(365),365)));
assertTrue(it.hasNext());
}
public void test466() {
d1.put(n(366),"366");
it = d1.entrySet().iterator();
assertTrue(d1.entrySet().remove(e(n(366),"366")));
assertException(ConcurrentModificationException.class, () -> it.hasNext());
}
public void test467() {
d1.put(n(367),"367");
it = d1.entrySet().iterator();
assertTrue(d1.entrySet().remove(e(n(367),"367")));
assertException(ConcurrentModificationException.class, () -> it.next());
}
public void test468() {
d1.put(n(368),"368");
it = d1.entrySet().iterator();
it.next();
assertTrue(d1.entrySet().remove(e(n(368),"368")));
assertException(ConcurrentModificationException.class, () -> it.hasNext());
}
public void test469() {
d1.put(n(369),"369");
it = d1.entrySet().iterator();
it.next();
assertTrue(d1.entrySet().remove(e(n(369),"369")));
assertException(ConcurrentModificationException.class, () -> it.remove());
}
/**
* test50x: Tests for remove subsets
*/
public void test500() {
makeTree();
for (Iterator it = d1.keySet().iterator(); it.hasNext();) {
it.next();
it.remove();
}
assertEquals(0,d1.size());
for (int i=0; i <= 140; ++i)
assertNull(d1.get(i));
}
public void test501() {
makeTree();
for (Iterator it = d1.keySet().iterator(); it.hasNext();)
if (((Integer.parseInt(it.next().rep,10) / 10) & 1) != 0)
it.remove();
assertEquals(6,d1.size());
for (int i=10; i <= 130; i += 10)
if (((i/10) & 1) == 0)
assertEquals(""+i,d1.get(n(i)));
else
assertNull("d1.get(n(" + i + ")) should have been removed (odd)",d1.get(n(i)));
}
public void test502() {
makeTree();
for (Iterator it = d1.keySet().iterator(); it.hasNext();)
if (((Integer.parseInt(it.next().rep,10) / 10) & 1) == 0)
it.remove();
assertEquals(7,d1.size());
for (int i=10; i <= 130; i += 10)
if (((i/10) & 1) != 0)
assertEquals(""+i,d1.get(n(i)));
else
assertNull("d1.get(n(" + i + ")) should have been removed (even)",d1.get(n(i)));
}
public void test503() {
makeTree();
for (Iterator it = d1.keySet().iterator(); it.hasNext();)
if (Integer.parseInt(it.next().rep,10) < 70)
it.remove();
assertEquals(7,d1.size());
for (int i=10; i <= 130; i += 10)
if (i > 60)
assertEquals(""+i,d1.get(n(i)));
else
assertNull("d1.get(n(" + i + ")) should have been removed (small)",d1.get(n(i)));
}
public void test504() {
makeTree();
for (Iterator it = d1.keySet().iterator(); it.hasNext();)
if (Integer.parseInt(it.next().rep,10) >= 70)
it.remove();
assertEquals(6,d1.size());
for (int i=10; i <= 130; i += 10)
if (i <= 60)
assertEquals(""+i,d1.get(n(i)));
else
assertNull("d1.get(n(" + i + ")) should have been removed (small)",d1.get(n(i)));
}
public void test550() {
makeTree();
assertNull(d1.get(null));
assertNull(d1.get("hello"));
assertNull(d1.get(n("hello")));
assertNull(d1.remove(null));
assertNull(d1.remove("hello"));
assertNull(d1.remove(n("hello")));
assertFalse(d1.containsKey(null));
assertFalse(d1.containsKey("hello"));
assertFalse(d1.containsKey(n("hello")));
assertFalse(d1.entrySet().contains(null));
assertFalse(d1.entrySet().contains("hello"));
assertFalse(d1.entrySet().contains(n("hello")));
assertFalse(d1.entrySet().contains(e("100",10)));
assertFalse(d1.entrySet().remove(null));
assertFalse(d1.entrySet().remove("hello"));
assertFalse(d1.entrySet().remove(n("hello")));
assertFalse(d1.entrySet().remove(e("100",10)));
}
private void testCollection(Collection l, String name, @SuppressWarnings("unchecked") T... parts)
{
assertEquals(name + ".size()",parts.length,l.size());
Iterator it = l.iterator();
int i=0;
while (it.hasNext() && i < parts.length) {
assertEquals(name + "[" + i + "]",parts[i],it.next());
++i;
}
assertFalse(name + " claims too long (iterator claims more elements)",it.hasNext());
try {
it.next();
assertFalse("iterator should have thrown exception, there is no next", true);
} catch(Exception e){
assertTrue(e instanceof NoSuchElementException);
}
assertFalse(name + " claims too short (iterator stops too soon, after " + i + " elements)",(i < parts.length));
}
}
TEST EFFICIENCY
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;
import junit.framework.TestCase;
import edu.uwm.cs351.ps.Dictionary;
import edu.uwm.cs351.ps.Name;
import edu.uwm.cs351.util.AbstractEntry;
public class TestEfficiency extends TestCase {
private Dictionary dict;
private Map tree;
private Random random;
private static final int POWER = 20; // 1/2 million entries
private static final int TESTS = 100_000;
private static final int PREFIX = 10_000_000;
protected static Name n(int i) {
return new Name("N" + (PREFIX+i));
}
protected Entry e(T k, U v) {
return new AbstractEntry() {
@Override
public T getKey() {
return k;
}
@Override
public U getValue() {
return v;
}
};
}
protected void setUp() throws Exception {
super.setUp();
random = new Random();
try {
assert dict.size() == TESTS : "cannot run test with assertions enabled";
} catch (NullPointerException ex) {
throw new IllegalStateException("Cannot run test with assertions enabled");
}
tree = dict = new Dictionary();
int max = (1 << (POWER)); // 2^(POWER) = 2 million
for (int power = POWER; power > 1; --power) {
int incr = 1 << power;
for (int i=1 << (power-1); i < max; i += incr) {
dict.put(n(i), power);
}
}
}
@Override
protected void tearDown() throws Exception {
dict = null;
super.tearDown();
}
public void testE0() {
for (int i=0; i < TESTS; ++i) {
assertEquals((1<<(POWER-1))-1,dict.size());
}
}
public void testE1() {
for (int i=0; i < TESTS; ++i) {
int r = random.nextInt(TESTS);
assertTrue(dict.known(n(r*4+2)));
assertEquals(Integer.valueOf(2),dict.get(n(r*4+2)));
assertFalse(dict.known(n(r*2+1)));
}
}
public void testE2() {
for (int i=0; i < TESTS; ++i) {
assertFalse(tree.isEmpty());
}
}
public void testE3() {
for (int i=0; i < TESTS; ++i) {
int r = random.nextInt(TESTS);
assertTrue(tree.containsKey(n(r*4+2)));
assertEquals(Integer.valueOf(2),tree.get(n(r*4+2)));
assertNull(tree.get(n(r*2+1)));
assertFalse(tree.containsKey(n(r*2+1)));
}
}
public void testE4() {
Set touched = new HashSet();
for (int i=0; i < TESTS; ++i) {
int r = random.nextInt(TESTS);
if (!touched.add(r)) continue; // don't check again
assertEquals(Integer.valueOf(2),tree.remove(n(r*4+2)));
assertNull(tree.remove(n(r*2+1)));
}
}
public void testE5() {
Iterator it = tree.keySet().iterator();
for (int i=0; i < TESTS; ++i) {
assertTrue("After " + i + " next(), should still have next",it.hasNext());
it.next();
}
}
public void testE6() {
for (int i=0; i < TESTS; ++i) {
Iterator it = tree.values().iterator();
assertTrue(it.hasNext());
assertEquals(Integer.valueOf(2),it.next());
assertTrue(it.hasNext());
assertEquals(Integer.valueOf(3),it.next());
assertTrue(it.hasNext());
}
}
public void testE7() {
for (int i=0; i < TESTS; ++i) {
int r = random.nextInt(TESTS);
assertFalse("should not contain bad entry for " + i,
tree.entrySet().contains(e(n(r*4+2),1)));
assertTrue("should contain entry for " + i,
tree.entrySet().contains(e(n(r*4+2),2)));
assertFalse("should not contain non-existent entry for " + i,
tree.entrySet().contains(e(n(r*4+1),2)));
}
}
public void testE8() {
Set touched = new HashSet();
for (int i=0; i < TESTS; ++i) {
int r = random.nextInt(TESTS);
if (!touched.add(r)) continue; // don't check again
assertFalse("should not be able to remove bad entry for " + i,
tree.entrySet().remove(e(n(r*4+2),1)));
assertTrue("should be able to remove entry for " + i,
tree.entrySet().remove(e(n(r*4+2),2)));
assertFalse("should not be able to remove non-existent entry for " + i,
tree.entrySet().remove(e(n(r*2+1),1)));
}
}
public void testE9() {
int removed = 0;
int max = (1 << POWER);
assertEquals(max/2-1,tree.size());
Iterator> it = tree.entrySet().iterator();
for (int i = 2; i < max; i += 2) {
it.next();
if (random.nextBoolean()) {
it.remove();
++removed;
}
}
assertEquals(max/2-1-removed,tree.size());
}
}
Similar Samples
Explore ProgrammingHomeworkHelp.com for comprehensive programming assignment samples. Our curated examples span Java, Python, C++, and more, showcasing expert solutions and clear coding methodologies. These samples serve as valuable learning tools, offering insights into complex programming concepts and practical application. Enhance your understanding and excel in programming with our meticulously crafted samples.
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java
Java