diff options
| author | pants <niklasjo2004@gmail.com> | 2026-09-21 14:16:34 -0700 |
|---|---|---|
| committer | pants <niklasjo2004@gmail.com> | 2026-09-21 14:16:34 -0700 |
| commit | 81ba9eb66f8284d8760012973f84cdbe617ceb94 (patch) | |
| tree | 466432644e9e3fd66ee183ec53a1f10abb1b7faa /debugging/Testing.java | |
Diffstat (limited to 'debugging/Testing.java')
| -rw-r--r-- | debugging/Testing.java | 40 |
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()); + } +} |
