1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import java.util.*;
- import static org.junit.Assert.*;
- import org.junit.Test;
-
-
- public class PhoneBookTest
- {
- @Test
- public void addTest(){
- PhoneBook phoneBook = new PhoneBook();
- phoneBook.add("vince","333-333-3333");
- int actual = phoneBook.size();
- int expected = 1;
- assertEquals(actual,expected);
- }
-
- @Test
- public void removeTest(){
- PhoneBook phoneBook = new PhoneBook();
- phoneBook.add("vince","333-333-3333");
- phoneBook.remove("vince");
- int actual = phoneBook.size();
- int expected = 0;
- assertEquals(actual,expected);
- }
-
- @Test
- public void lookupTest(){
- PhoneBook phoneBook = new PhoneBook();
- phoneBook.add("vince","333-333-3333");
- String actual = phoneBook.lookup("vince");
- String expected = "333-333-3333";
- assertEquals(actual,expected);
- }
- @Test
- public void lookupReverseTest(){
- PhoneBook phoneBook = new PhoneBook();
- phoneBook.add("vince","333-333-3333");
- String actual = phoneBook.reverseLookup("333-333-3333");
- String expected = "vince";
- assertEquals(actual,expected);
- }
-
- @Test
- public void displayTest(){
- PhoneBook phoneBook = new PhoneBook();
- phoneBook.add("vince","333-333-3333");
- phoneBook.add("bill","444-444-4444");
- phoneBook.add("john","555-555-5555");
- String actual = phoneBook.display();
- String expected = "bill : 444-444-4444\njohn : 555-555-5555\nvince : 333-333-3333\n";
- assertEquals(actual,expected);
- }
-
- }
|