|
@@ -1,42 +1,37 @@
|
1
|
1
|
|
2
|
|
-
|
3
|
2
|
import static org.junit.Assert.*;
|
4
|
3
|
import org.junit.After;
|
5
|
4
|
import org.junit.Before;
|
6
|
5
|
import org.junit.Test;
|
7
|
6
|
|
8
|
|
-/**
|
9
|
|
- * The test class PhoneBookTest.
|
10
|
|
- *
|
11
|
|
- * @author (your name)
|
12
|
|
- * @version (a version number or a date)
|
13
|
|
- */
|
14
|
7
|
public class PhoneBookTest
|
15
|
8
|
{
|
16
|
|
- /**
|
17
|
|
- * Default constructor for test class PhoneBookTest
|
18
|
|
- */
|
19
|
|
- public PhoneBookTest()
|
20
|
|
- {
|
|
9
|
+ @Test
|
|
10
|
+ public void testAdd(){
|
|
11
|
+ PhoneBook phonebook = new PhoneBook();
|
|
12
|
+ String expected = "1234567890";
|
|
13
|
+ phonebook.add("tyler",expected);
|
|
14
|
+ String actual = phonebook.lookUp("tyler");
|
|
15
|
+ assertEquals(actual, expected);
|
|
16
|
+
|
21
|
17
|
}
|
22
|
18
|
|
23
|
|
- /**
|
24
|
|
- * Sets up the test fixture.
|
25
|
|
- *
|
26
|
|
- * Called before every test case method.
|
27
|
|
- */
|
28
|
|
- @Before
|
29
|
|
- public void setUp()
|
30
|
|
- {
|
|
19
|
+ @Test
|
|
20
|
+ public void testLookUp(){
|
|
21
|
+ PhoneBook phonebook = new PhoneBook();
|
|
22
|
+ String expected = "1234567890";
|
|
23
|
+ phonebook.add("tyler", expected);
|
|
24
|
+ String actual = phonebook.lookUp("tyler");
|
|
25
|
+ assertEquals(expected, actual);
|
31
|
26
|
}
|
32
|
27
|
|
33
|
|
- /**
|
34
|
|
- * Tears down the test fixture.
|
35
|
|
- *
|
36
|
|
- * Called after every test case method.
|
37
|
|
- */
|
38
|
|
- @After
|
39
|
|
- public void tearDown()
|
40
|
|
- {
|
|
28
|
+ @Test
|
|
29
|
+ public void testReverse(){
|
|
30
|
+ PhoneBook phonebook = new PhoneBook();
|
|
31
|
+ String expected = "tyler";
|
|
32
|
+ phonebook.add("tyler", "1234567890");
|
|
33
|
+ String actual = phonebook.reverseLookUp("1234567890");
|
|
34
|
+ assertEquals(expected, actual);
|
41
|
35
|
}
|
|
36
|
+
|
42
|
37
|
}
|