Skip to content

Commit

Permalink
Update text ui testing
Browse files Browse the repository at this point in the history
  • Loading branch information
AlWo223 committed Oct 3, 2023
1 parent 1ec2d40 commit 6b70ff7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 8 deletions.
2 changes: 0 additions & 2 deletions data/duke.txt
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
T | 0 | read book
T | 0 | buy Book
2 changes: 1 addition & 1 deletion src/main/java/duke/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public ArrayList<Task> loadData() {
readDataLine(input);
}
} catch (IOException e) {
System.out.println("An error occurred when accessing the file.");
System.out.println("Data file not found, creating new file.");
}
return tasks;
}
Expand Down
11 changes: 10 additions & 1 deletion text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Data file not found, creating new file.
____ _
| _ \ _ _| | _____
| | | | | | | |/ / _ \
Expand Down Expand Up @@ -52,6 +53,14 @@ Here are the matching tasks in your list:
1.[T][ ] join book club
2.[T][ ] borrow book
--------------------------------------------
Ok, I have added the following task:
[D][ ] apply to Harvard (by: Dec-06-2023 23:59)
Now you have 4 tasks in the list.
--------------------------------------------
Ok, I have added the following task:
[D][ ] organize present for birthday party (by: Aug-08-2023 14:00)
Now you have 5 tasks in the list.
--------------------------------------------
--------------------------------------------
Have a wonderful day! Hope to see you again soon!
--------------------------------------------
--------------------------------------------
5 changes: 5 additions & 0 deletions text-ui-test/data/duke.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
E | 0 | project meeting | Aug-06-2022 13:00 | Aug-06-2022 14:00
T | 0 | join book club
T | 0 | borrow book
D | 0 | apply to Harvard | Dec-06-2023 23:59
D | 0 | organize present for birthday party | Aug-08-2023 14:00
1 change: 0 additions & 1 deletion text-ui-test/input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ delete
mark
todo borrow book
find book
--
deadline apply to Harvard /by 2023-12-06 23:59
deadline organize present for birthday party /by 2023-08-08 14:00
bye
11 changes: 8 additions & 3 deletions text-ui-test/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,27 @@ then
rm ACTUAL.TXT
fi

if [ -e "./data/duke.txt" ]
then
rm data/duke.txt
fi

# compile the code into the bin folder, terminates if error occurred
if ! javac -cp ../src/main/java -Xlint:none -d ../bin ../src/main/java/*.java
if ! javac -cp ../src/main/java -Xlint:none -d ../bin ../src/main/java/duke/**/*.java
then
echo "********** BUILD FAILURE **********"
exit 1
fi

# 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

# convert to UNIX format
cp EXPECTED.TXT EXPECTED-UNIX.TXT
dos2unix ACTUAL.TXT EXPECTED-UNIX.TXT

# compare the output to the expected output
diff ACTUAL.TXT EXPECTED-UNIX.TXT
diff -w ACTUAL.TXT EXPECTED-UNIX.TXT
if [ $? -eq 0 ]
then
echo "Test result: PASSED"
Expand Down

0 comments on commit 6b70ff7

Please sign in to comment.