123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- 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<>();
- 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");
- testPhonebook.get("9393939");
-
- String actual = testPhonebook.get("Hirself");
- String expected = "9393939";
- assertEquals(actual, expected);
- }
-
-
- }
|