summaryrefslogtreecommitdiff
path: root/debugging/Testing.java
diff options
context:
space:
mode:
Diffstat (limited to 'debugging/Testing.java')
-rw-r--r--debugging/Testing.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/debugging/Testing.java b/debugging/Testing.java
new file mode 100644
index 0000000..a50fe62
--- /dev/null
+++ b/debugging/Testing.java
@@ -0,0 +1,40 @@
+import org.junit.jupiter.api.*;
+import static org.junit.jupiter.api.Assertions.*;
+import java.util.*;
+
+public class Testing {
+
+ @Test
+ @DisplayName("EXAMPLE TEST CASE - createIndex Example")
+ public void firstCaseTest() {
+ List<String> documents = new ArrayList<>(List.of("The Bee Movie is great!",
+ "I love the Bee Movie",
+ "Y'all seen Dune 2?"));
+ Map<String, Set<String>> index = InvertedIndex.createIndex(documents);
+
+ // Make sure that tokens are correctly converted to lower case
+ assertTrue(index.containsKey("bee"));
+ assertFalse(index.containsKey("Bee"));
+
+ // Make sure that punctuation is ignored
+ assertTrue(index.containsKey("great!"));
+ assertFalse(index.containsKey("great"));
+
+ // Check one of the sets
+ assertEquals(Set.of("The Bee Movie is great!",
+ "I love the Bee Movie"),
+ index.get("movie"));
+ }
+
+ @Test
+ @DisplayName("EXAMPLE TEST CASE - Book 2 String constructor + getters")
+ public void secondCaseTest() {
+ Book b = new Book("Title", "Author");
+
+ // Test all getters after constructing with 2 Strings
+ assertEquals("Title", b.getTitle());
+ assertEquals(List.of("Author"), b.getArtists());
+ assertEquals(0, b.getNumRatings());
+ assertEquals(0.0, b.getAverageRating());
+ }
+}