对上文BST的10个公开api的实现进行测试(size()方法在其他测试方法内部已测)。
具体junit4下的测试类:
import static org.junit.Assert.assertEquals;
import org.junit.BeforeClass;
import org.junit.Test;
public class TestBST {
static BST<String, Integer> b;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
b = new BST<String, Integer>();
}
@Test
public void testPut() {
b.put("alice", 100);
b.put("alice", 100);
assertEquals(1, b.size());
}
@Test
public void testGet() {
b.put("bob", 88);
b.put("bob", 38);
int i = b.get("bob");
assertEquals(38, i);
}
@Test
public void testDelete() {
b.put(&#