Skip to content

Commit

Permalink
Fix JUnit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jehousoh committed Sep 14, 2022
1 parent f058afe commit 83c0ca5
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 36 deletions.
1 change: 0 additions & 1 deletion data/duke.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
[T]--[ ]--hii
21 changes: 20 additions & 1 deletion src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package duke;

import java.util.Scanner;

import duke.helper.Parser;
import duke.helper.Storage;
import duke.helper.Ui;
Expand Down Expand Up @@ -34,7 +36,24 @@ public String getResponse(String input) {
return Parser.parse(input, list, filePath);
}

/**
* Main method to run Duke
*
* @param args the args for the main method
*/
public static void main(String[] args) {
new Duke("./data/duke.txt").run();
Duke duke = new Duke("./data/duke.txt");
System.out.println(Ui.welcome());
String in = "";
Scanner sc = new Scanner(System.in);
while (true) {
in = sc.nextLine();
if (in.equals("bye")) {
break;
} else {
System.out.println(duke.getResponse(in));
}
}
System.out.println(duke.getResponse(in));
}
}
7 changes: 7 additions & 0 deletions src/main/java/duke/helper/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ public static String delete(String in, TaskList list) {
}
}

/**
* Method to create Task
*
* @param in the input string given
* @param list the tasklist to add the task to
* @return a string describing if the task creation was successful
*/
public static String createTask(String in, TaskList list) {
String message;
try {
Expand Down
71 changes: 40 additions & 31 deletions text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
@@ -1,73 +1,82 @@
-------------------------------------------

Hello from Phil
How may I assist you on this fine day?
-------------------------------------------
type 'help' to get a lists of all the commands!

The list has been successfully cleared!
-------------------------------------------

added: [T][ ] borrow book
-------------------------------------------

added: [D][ ] return book (by: Sunday)
-------------------------------------------

added: [E][ ] project meeting (at: Mon 2-4pm)
-------------------------------------------

1.[T][ ] borrow book
2.[D][ ] return book (by: Sunday)
3.[E][ ] project meeting (at: Mon 2-4pm)
-------------------------------------------


Roger sir the task has been marked!
-------------------------------------------

Roger sir the task has been marked!
-------------------------------------------

1.[T][X] borrow book
2.[D][ ] return book (by: Sunday)
3.[E][X] project meeting (at: Mon 2-4pm)
-------------------------------------------


Aww okay the task has been unmarked.
-------------------------------------------

1.[T][ ] borrow book
2.[D][ ] return book (by: Sunday)
3.[E][X] project meeting (at: Mon 2-4pm)
-------------------------------------------


Your task has to have description :<
-------------------------------------------

Your task has to have description :<
-------------------------------------------

Your task has to have description :<
-------------------------------------------

Your task has to have description :<
-------------------------------------------

Your task has to have description :<
-------------------------------------------

Please precede your date/time with a '/by' for a deadline and an '/at' for an event
-------------------------------------------

Please precede your date/time with a '/by' for a deadline and an '/at' for an event
-------------------------------------------

1.[T][ ] borrow book
2.[D][ ] return book (by: Sunday)
3.[E][X] project meeting (at: Mon 2-4pm)
-------------------------------------------


Alrighty! I have deleted the following task:
[T][ ] borrow book
We now have 2 tasks left.
-------------------------------------------

1.[D][ ] return book (by: Sunday)
2.[E][X] project meeting (at: Mon 2-4pm)
-------------------------------------------


Alrighty! I have deleted the following task:
[E][X] project meeting (at: Mon 2-4pm)
We now have 1 tasks left.
-------------------------------------------

1.[D][ ] return book (by: Sunday)
-------------------------------------------


Invalid command. Please try again.
-------------------------------------------

added: [D][ ] watch lecture (by: Aug 30 2022)
-------------------------------------------

added: [D][ ] submit quiz (by: Aug 23 2022 11:59 PM)
-------------------------------------------
1.[D][ ] return book (by: Sunday)

Roger sir the task has been marked!

1.[D][X] return book (by: Sunday)
2.[D][ ] watch lecture (by: Aug 30 2022)
3.[D][ ] submit quiz (by: Aug 23 2022 11:59 PM)
-------------------------------------------
See you later alligator!
-------------------------------------------


I shall take my leave in 3 seconds! See you later alligator!
2 changes: 1 addition & 1 deletion text-ui-test/data/duke.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[D]--[ ]--return book--Sunday
[D]--[X]--return book--Sunday
[D]--[ ]--watch lecture--Aug 30 2022
[D]--[ ]--submit quiz--Aug 23 2022 11:59 PM
1 change: 1 addition & 0 deletions text-ui-test/input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ list
delete 3
deadline watch lecture /by 2022-8-30
deadline submit quiz /by 2022-8-23 2359
mark 1
list
bye
4 changes: 2 additions & 2 deletions text-ui-test/runtest.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ REM delete output from previous run
if exist ACTUAL.TXT del ACTUAL.TXT

REM compile the code into the bin folder
javac -cp ..\src\main\java -Xlint:none -d ..\bin ..\src\main\java\*.java
javac -cp ..\src\main\java -Xlint:none -d ..\bin ..\src\main\java\duke\*.java
IF ERRORLEVEL 1 (
echo ********** BUILD FAILURE **********
exit /b 1
)
REM no error here, errorlevel == 0

REM run the program, feed commands from input.txt file and redirect the output to the ACTUAL.TXT
java -classpath ..\bin Duke < input.txt > ACTUAL.TXT
java -classpath ..\bin duke/Duke < input.txt > ACTUAL.TXT

REM compare the output to the expected output
FC ACTUAL.TXT EXPECTED.TXT

0 comments on commit 83c0ca5

Please sign in to comment.