Skip to content

Commit

Permalink
Merge pull request #208 from liuzehui03/master
Browse files Browse the repository at this point in the history
Added JUNIT for find genre
  • Loading branch information
liuzehui03 authored Apr 15, 2024
2 parents 7b274bf + 37f6238 commit 94c732e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/test/java/seedu/bookbuddy/ParserMainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,33 @@ void parseFindTitleCommand() {

assertEquals(expectedOutput, actualOutput);
}
@Test
void parseFindGenreFictionCommand() {
BookList books = new BookList();
BookListModifier.addBook(books, "The Great Gatsby");
BookListModifier.addBook(books, "Nineteen Eighty-Four");
BookListModifier.addBook(books, "Percy Jackson");
BookListModifier.addBook(books, "Brave New World");

// Set genres for the books
ParserMain.parseCommand("set-genre 1 Fiction", books);
ParserMain.parseCommand("set-genre 4 Fiction", books);

ByteArrayOutputStream outContent = new ByteArrayOutputStream();
System.setOut(new PrintStream(outContent));

ParserMain.parseCommand("find-genre Fiction", books);

String actualOutput = outContent.toString().replace("\r\n", "\n");

String expectedOutput = "___________________________________\n" +
"fiction books: \n" +
"1. [U] The Great Gatsby\n" +
"2. [U] Brave New World\n" +
"_____________\n";

assertEquals(expectedOutput, actualOutput);
}

@Test
void parseFindLabelCommand() {
Expand Down

0 comments on commit 94c732e

Please sign in to comment.