Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove \r symbols during testing. #88

Merged
merged 3 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/seedu/duke/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class Ui {
"[-details]: show the details of the problem set(each individual problem).";
private static final String RETRY_COMMAND =
"Retry a problem set you have solved before in the past: \t" + "retry PROBLEM_SET_ID\n" +
"PROBLEM_SET_ID is an integer, and can be found by using the 'records' command.\n";
private static final String EXIT_COMMAND = "Exit program: exit\n";
"PROBLEM_SET_ID is an integer, and can be found by using the 'records' command.";
private static final String EXIT_COMMAND = "Exit program: exit";
// msg for other classes
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

Expand Down
17 changes: 11 additions & 6 deletions src/test/java/seedu/duke/UiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ public class UiTest {
private Ui ui;
private final ByteArrayOutputStream output = new ByteArrayOutputStream();

public String cleanOutput() {
String res = output.toString().replaceAll("\n", "");
res = res.replaceAll("\r", "");
res = res.replaceAll("\t", "");
return res;
}

@BeforeEach
public void setUp() {
ui = new Ui("ChatBot");
Expand All @@ -31,22 +38,20 @@ public void helpTest() {
"and the maximum number of digits is 2 (99 max)" +
"=========================";
String cleanOutput = output.toString().replaceAll("\n", "").replaceAll("\t", "");

assertEquals(expectedOutput, cleanOutput);
cleanOutput = cleanOutput.replaceAll("\r", "");
assertEquals(expectedOutput, cleanOutput());
}


@Test
public void invalidCommandTest() {
ui.invalidCommand();
String cleanOutput = output.toString().replaceAll("\n", "").replaceAll("\t", "");
assertEquals("Invalid command! Please try again.=========================", cleanOutput);
assertEquals("Invalid command! Please try again.=========================", cleanOutput());
}

@Test
public void exitTest() {
ui.exit();
String cleanOutput = output.toString().replaceAll("\n", "").replaceAll("\t", "");
assertEquals("Bye. Hope to see you again soon!=========================", cleanOutput);
assertEquals("Bye. Hope to see you again soon!=========================", cleanOutput());
}
}
Loading