This repository has been archived on 2026-03-18. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
CSE-123/debugging/Testing.java
2026-03-18 00:39:35 -07:00

41 lines
1.5 KiB
Java

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());
}
}