123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import java.util.*;
-
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
- public class PhoneBookTest{
- Map<String, String> testPhonebook = new TreeMap<>();
- Collection<String> c;
- Iterator<String> iter = c.iterator();
- public PhoneBookTest(){
- }
-
- @Test
- public void addTest(){
- String number = "302-559-6954";
- String name = "Ken";
-
- testPhonebook.put(number, name);
- String expected = testPhonebook.get(number);
- assertEquals(name, expected);
- }
-
- @Test
- public void removeTest(){
- testPhonebook.put("9393939", "Hirself");
- testPhonebook.remove("9393939");
-
- String actual = testPhonebook.get("9393939");
- String expected = null;
- assertEquals(actual, expected);
- }
-
- @Test
- public void lookupTest(){
- testPhonebook.put("9393939", "Hirself");
- testPhonebook.get("9393939");
-
- String actual = testPhonebook.get("9393939");
- String expected = "Hirself";
- assertEquals(actual, expected);
- }
-
- @Test
- public void reverseLookupTest(){
- testPhonebook.put("9393939", "Hirself");
-
- String actual = testPhonebook.get("9393939");
- String expected = "Hirself";
- assertEquals(actual, expected);
- }
-
- @Test
- public void removeRecordTest(){
- testPhonebook.put("9393939", "Hirself");
- testPhonebook.put("8484848", "Moped");
-
- for(TreeMap<String, String> entry : c){
- entry.remove();
- }
- String actual = null;
- }
-
-
- }
|