|
@@ -65,10 +65,88 @@ public class PhoneBookTest
|
65
|
65
|
}
|
66
|
66
|
|
67
|
67
|
@Test
|
68
|
|
- public void testReverseLookup(){
|
|
68
|
+ public void testReverseLookup1(){
|
|
69
|
+ PhoneBook pb = new PhoneBook();
|
|
70
|
+
|
|
71
|
+ String expected = "Joe";
|
|
72
|
+
|
|
73
|
+ pb.addEntrant("Josh" , "123", "456", "789");
|
|
74
|
+ pb.addEntrant("John" , "321", "654", "987");
|
|
75
|
+ pb.addEntrant("Joe" , "111", "222", "333");
|
69
|
76
|
|
|
77
|
+ String actual = pb.reverseLookup("222");
|
70
|
78
|
|
|
79
|
+ assertEquals(expected, actual);
|
71
|
80
|
}
|
72
|
81
|
|
|
82
|
+ @Test
|
|
83
|
+ public void testReverseLookup2(){
|
|
84
|
+ PhoneBook pb = new PhoneBook();
|
|
85
|
+
|
|
86
|
+ String expected = "John";
|
|
87
|
+
|
|
88
|
+ pb.addEntrant("Josh" , "123", "456", "789");
|
|
89
|
+ pb.addEntrant("John" , "321", "654", "987");
|
|
90
|
+ pb.addEntrant("Joe" , "111", "222", "333");
|
|
91
|
+
|
|
92
|
+ String actual = pb.reverseLookup("654");
|
|
93
|
+
|
|
94
|
+ assertEquals(expected, actual);
|
|
95
|
+ }
|
|
96
|
+
|
|
97
|
+ @Test
|
|
98
|
+ public void testAddNumber1(){
|
|
99
|
+ PhoneBook pb = new PhoneBook();
|
|
100
|
+
|
|
101
|
+ String expected = "123, 456";
|
|
102
|
+
|
|
103
|
+ pb.addEntrant("Josh" , "123");
|
|
104
|
+ pb.addNumber("Josh","456");
|
|
105
|
+
|
|
106
|
+ String actual = pb.lookup("Josh");
|
|
107
|
+ assertEquals(expected, actual);
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+ @Test
|
|
111
|
+ public void testAddNumber2(){
|
|
112
|
+ PhoneBook pb = new PhoneBook();
|
|
113
|
+
|
|
114
|
+ String expected = "123, 456, 789";
|
|
115
|
+
|
|
116
|
+ pb.addEntrant("Jim" , "123");
|
|
117
|
+ pb.addNumber("Jim","456");
|
|
118
|
+ pb.addNumber("Jim","789");
|
|
119
|
+
|
|
120
|
+ String actual = pb.lookup("Jim");
|
|
121
|
+ assertEquals(expected, actual);
|
|
122
|
+ }
|
|
123
|
+
|
|
124
|
+ @Test
|
|
125
|
+ public void testRemoveNumber1(){
|
|
126
|
+ PhoneBook pb = new PhoneBook();
|
|
127
|
+
|
|
128
|
+ String expected = "123, 456";
|
|
129
|
+
|
|
130
|
+ pb.addEntrant("Jim" , "123", "456", "789");
|
|
131
|
+ pb.removeNumber("Jim", "789");
|
|
132
|
+
|
|
133
|
+ String actual = pb.lookup("Jim");
|
|
134
|
+ assertEquals(expected, actual);
|
|
135
|
+ }
|
|
136
|
+
|
|
137
|
+ @Test
|
|
138
|
+ public void testRemoveNumber2(){
|
|
139
|
+ PhoneBook pb = new PhoneBook();
|
|
140
|
+
|
|
141
|
+ String expected = "123, 789";
|
|
142
|
+
|
|
143
|
+ pb.addEntrant("Jim" , "123", "456", "789");
|
|
144
|
+ pb.removeNumber("Jim", "456");
|
|
145
|
+
|
|
146
|
+ String actual = pb.lookup("Jim");
|
|
147
|
+ assertEquals(expected, actual);
|
|
148
|
+ }
|
|
149
|
+
|
|
150
|
+
|
73
|
151
|
|
74
|
152
|
}
|