From 8e0d78c1b52e84dfbdb2765d9c4183ab2116c2d1 Mon Sep 17 00:00:00 2001 From: Haidong Ji Date: Sat, 9 Mar 2019 19:06:35 -0600 Subject: 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. --- src/test/PhoneBookTest.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/test/PhoneBookTest.java (limited to 'src/test') 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 -- cgit v1.2.3