summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorHaidong Ji2019-03-09 19:06:35 -0600
committerHaidong Ji2019-03-09 19:06:35 -0600
commit8e0d78c1b52e84dfbdb2765d9c4183ab2116c2d1 (patch)
tree80684bc5e5d745c49016c2860e41273310f5fe92 /src/test
parentbf3c1de9f72097bc5a6937344f9402854ce18abc (diff)
Phone book done!
I cheated and didn't modify the starter code so it's testable. It seems that starter code in this course is not written as well as the first course.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/PhoneBookTest.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/PhoneBookTest.java b/src/test/PhoneBookTest.java
new file mode 100644
index 0000000..fb898f0
--- /dev/null
+++ b/src/test/PhoneBookTest.java
@@ -0,0 +1,26 @@
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class PhoneBookTest {
+ @Test
+ void test() {
+ PhoneBook.add(911, "police");
+ PhoneBook.add(76213, "Mom");
+ PhoneBook.add(17239, "Bob");
+
+ assertEquals("Mom", PhoneBook.find(76213));
+ assertEquals("not found", PhoneBook.find(910));
+ assertEquals("police", PhoneBook.find(911));
+
+ PhoneBook.del(910);
+ PhoneBook.del(911);
+
+ assertEquals("not found", PhoneBook.find(911));
+ assertEquals("Mom", PhoneBook.find(76213));
+
+ PhoneBook.add(76213, "daddy");
+ assertEquals("daddy", PhoneBook.find(76213));
+ }
+
+} \ No newline at end of file