diff --git a/data/duke.txt b/data/duke.txt index a02c21449..e69de29bb 100644 --- a/data/duke.txt +++ b/data/duke.txt @@ -1,2 +0,0 @@ -T | 0 | read book -T | 0 | buy Book diff --git a/src/main/java/duke/Storage.java b/src/main/java/duke/Storage.java index 5e24cc65d..a3e22473f 100644 --- a/src/main/java/duke/Storage.java +++ b/src/main/java/duke/Storage.java @@ -44,7 +44,7 @@ public ArrayList 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; } diff --git a/text-ui-test/EXPECTED.TXT b/text-ui-test/EXPECTED.TXT index b7ef84d08..5dd7670a7 100644 --- a/text-ui-test/EXPECTED.TXT +++ b/text-ui-test/EXPECTED.TXT @@ -1,3 +1,4 @@ +Data file not found, creating new file. ____ _ | _ \ _ _| | _____ | | | | | | | |/ / _ \ @@ -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! --------------------------------------------- \ No newline at end of file +-------------------------------------------- diff --git a/text-ui-test/data/duke.txt b/text-ui-test/data/duke.txt new file mode 100644 index 000000000..0e007aeb4 --- /dev/null +++ b/text-ui-test/data/duke.txt @@ -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 diff --git a/text-ui-test/input.txt b/text-ui-test/input.txt index 4beef7be9..8bcbe1480 100644 --- a/text-ui-test/input.txt +++ b/text-ui-test/input.txt @@ -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 \ No newline at end of file diff --git a/text-ui-test/runtest.sh b/text-ui-test/runtest.sh index c9ec87003..d8ec1ed3d 100644 --- a/text-ui-test/runtest.sh +++ b/text-ui-test/runtest.sh @@ -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"