Skip to content

Commit

Permalink
Merge branch 'branch-zongyao-exceptionhandling' of https://github.com…
Browse files Browse the repository at this point in the history
…/yeozongyao/tp into branch-zongyao-exceptionhandling

* 'branch-zongyao-exceptionhandling' of https://github.com/yeozongyao/tp:
  checkstyle fixes - \r\n on windows system and \n on unix systems
  checkstyle fixes - unused imports
  checkstyle fixes
  checkstyle fixes
  checkstyle fixes
  checkstyle fixes
  checkstyle fixes
  checkstyle fixes
  Checkstyle fixes - empty spaces. For Gradle Checkstyle
  Checkstyle fix - newline at the end of file
  Checkstyle fixes

# Conflicts:
#	src/test/java/seedu/bookbuddy/ParserTest.java
  • Loading branch information
yeozongyao committed Mar 19, 2024
2 parents 815f18c + 5099f38 commit 8517cfb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 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
3 changes: 1 addition & 2 deletions src/test/java/seedu/bookbuddy/ParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
import exceptions.InvalidCommandArgumentException;
import exceptions.UnsupportedCommandException;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;


public class ParserTest {
@Test
void testParser() {
Expand Down

0 comments on commit 8517cfb

Please sign in to comment.