Skip to content

Commit

Permalink
Merge branch 'master' into branch-zongyao-exceptionhandling
Browse files Browse the repository at this point in the history
  • Loading branch information
yeozongyao authored Mar 19, 2024
2 parents 0306eda + 8080b31 commit 5099f38
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
17 changes: 13 additions & 4 deletions src/test/java/seedu/bookbuddy/BookBuddyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,24 @@ public void sampleTest() {
@Test
public void testPrintWelcomeMessage() {
BookBuddy.printWelcomeMessage();
String expectedOutput = "Hello! We are BookBuddy!\nHow can I help you today?\n";
assertEquals(expectedOutput, outContent.toString());
String actualOutput = outContent.toString();

// Normalize line endings to \n in both expected and actual output
String normalizedExpectedOutput = "Hello! We are BookBuddy!\nHow can I help you today?\n".replace("\r\n", "\n");
String normalizedActualOutput = actualOutput.replace("\r\n", "\n");

// Assert that the normalized outputs are equal
assertEquals(normalizedExpectedOutput, normalizedActualOutput);
}




@Test
public void testPrintExitMessage() {
BookBuddy.printExitMessage();
String expectedOutput = "Thank you for using BookBuddy! Hope to see you again!\n";
assertEquals(expectedOutput, outContent.toString());
assertEquals(expectedOutput.trim(), outContent.toString().trim());
}

}
}
7 changes: 5 additions & 2 deletions src/test/java/seedu/bookbuddy/BookListTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;



class BookListTest {
Expand Down Expand Up @@ -34,7 +36,8 @@ void printAllBooks() {
testBookList.printAllBooks();

String expectedOutput = "All books:\n1. [U] Harry Potter\n";
assertEquals(expectedOutput, outContent.toString());
String normalizedActualOutput = outContent.toString().replace("\r\n", "\n");
assertEquals(expectedOutput.trim(), normalizedActualOutput.trim());

System.setOut(System.out);
}
Expand Down
4 changes: 3 additions & 1 deletion src/test/java/seedu/bookbuddy/ParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;

public class ParserTest {
@Test
Expand Down

0 comments on commit 5099f38

Please sign in to comment.