From af2844e6a4d9433cbf1406220336d41462a86b06 Mon Sep 17 00:00:00 2001 From: LongLeCE Date: Mon, 11 Nov 2019 16:36:42 +0800 Subject: [PATCH 1/2] Ignore carriage return for input --- src/main/java/planner/ui/cli/PlannerUi.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/planner/ui/cli/PlannerUi.java b/src/main/java/planner/ui/cli/PlannerUi.java index 0fe3bd46b7..8f095cca50 100644 --- a/src/main/java/planner/ui/cli/PlannerUi.java +++ b/src/main/java/planner/ui/cli/PlannerUi.java @@ -173,11 +173,16 @@ public String readInput(InputStream stream) { return null; } StringBuilder input = new StringBuilder(); - for (char c = (char) stream.read(); + char c; + for (c = (char) stream.read(); c != '\n' && c != '\uFFFF'; c = (char) stream.read()) { - input.append(c); + if (c != '\r') { + input.append(c); + } + System.out.println(c); } + System.out.println(c); if (input.length() == 0) { return null; } From 15fcb96f1bec49168221459dd611dd6dab7fe56e Mon Sep 17 00:00:00 2001 From: LongLeCE Date: Mon, 11 Nov 2019 16:44:26 +0800 Subject: [PATCH 2/2] Renamed some test classes for naming coherence --- src/test/java/planner/credential/user/TaskListsTest.java | 2 ++ .../logic/command/{ClearCommandTest.java => ClearTest.java} | 4 ++-- .../command/{CommandTestFramework.java => CommandTest.java} | 4 ++-- src/test/java/planner/logic/command/SortCcaTest.java | 2 +- src/test/java/planner/logic/command/SortModuleTest.java | 2 +- src/test/java/planner/logic/command/SortTimeTest.java | 2 +- src/test/java/planner/main/PlannerTest.java | 4 ++-- 7 files changed, 11 insertions(+), 9 deletions(-) rename src/test/java/planner/logic/command/{ClearCommandTest.java => ClearTest.java} (98%) rename src/test/java/planner/logic/command/{CommandTestFramework.java => CommandTest.java} (96%) diff --git a/src/test/java/planner/credential/user/TaskListsTest.java b/src/test/java/planner/credential/user/TaskListsTest.java index 5f00061ec4..85e21c0855 100644 --- a/src/test/java/planner/credential/user/TaskListsTest.java +++ b/src/test/java/planner/credential/user/TaskListsTest.java @@ -1,3 +1,5 @@ +//@@author LongLeCE + package planner.credential.user; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/planner/logic/command/ClearCommandTest.java b/src/test/java/planner/logic/command/ClearTest.java similarity index 98% rename from src/test/java/planner/logic/command/ClearCommandTest.java rename to src/test/java/planner/logic/command/ClearTest.java index cb588e1f63..d9a159feb8 100644 --- a/src/test/java/planner/logic/command/ClearCommandTest.java +++ b/src/test/java/planner/logic/command/ClearTest.java @@ -14,7 +14,7 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; -public class ClearCommandTest extends CommandTestFramework { +public class ClearTest extends CommandTest { private static final TaskList emptyCcaList = new TaskList<>(); private static final TaskList emptyModuleList = new TaskList<>(); @@ -34,7 +34,7 @@ public class ClearCommandTest extends CommandTestFramework { + "scheduleCca 1"; private String inputModule = inputCca; - ClearCommandTest() throws ModException { + ClearTest() throws ModException { super(); } diff --git a/src/test/java/planner/logic/command/CommandTestFramework.java b/src/test/java/planner/logic/command/CommandTest.java similarity index 96% rename from src/test/java/planner/logic/command/CommandTestFramework.java rename to src/test/java/planner/logic/command/CommandTest.java index ed17bb9f23..41909f24a9 100644 --- a/src/test/java/planner/logic/command/CommandTestFramework.java +++ b/src/test/java/planner/logic/command/CommandTest.java @@ -14,7 +14,7 @@ import java.io.ByteArrayInputStream; import java.util.HashMap; -public class CommandTestFramework extends InputTest { +public class CommandTest extends InputTest { User user; HashMap modDetail; @@ -24,7 +24,7 @@ public class CommandTestFramework extends InputTest { ModuleCommand command; Parser parser; - public CommandTestFramework() throws ModException { + public CommandTest() throws ModException { init(); } diff --git a/src/test/java/planner/logic/command/SortCcaTest.java b/src/test/java/planner/logic/command/SortCcaTest.java index ae4e4b75e6..c11f09e189 100644 --- a/src/test/java/planner/logic/command/SortCcaTest.java +++ b/src/test/java/planner/logic/command/SortCcaTest.java @@ -26,7 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class SortCcaTest extends CommandTestFramework { +public class SortCcaTest extends CommandTest { private static Storage store; private static ModuleTasksList modTasks; private static Parser argparser; diff --git a/src/test/java/planner/logic/command/SortModuleTest.java b/src/test/java/planner/logic/command/SortModuleTest.java index 6849d5ead6..aa47a1625a 100644 --- a/src/test/java/planner/logic/command/SortModuleTest.java +++ b/src/test/java/planner/logic/command/SortModuleTest.java @@ -25,7 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class SortModuleTest extends CommandTestFramework { +public class SortModuleTest extends CommandTest { private static Storage store; private static ModuleTasksList modTasks; private static Parser argparser; diff --git a/src/test/java/planner/logic/command/SortTimeTest.java b/src/test/java/planner/logic/command/SortTimeTest.java index ac2cdff739..7c99092068 100644 --- a/src/test/java/planner/logic/command/SortTimeTest.java +++ b/src/test/java/planner/logic/command/SortTimeTest.java @@ -25,7 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -public class SortTimeTest extends CommandTestFramework { +public class SortTimeTest extends CommandTest { private static Storage store; private static ModuleTasksList modTasks; private static Parser argparser; diff --git a/src/test/java/planner/main/PlannerTest.java b/src/test/java/planner/main/PlannerTest.java index f37f008986..005429a447 100644 --- a/src/test/java/planner/main/PlannerTest.java +++ b/src/test/java/planner/main/PlannerTest.java @@ -4,12 +4,12 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import planner.logic.command.CommandTestFramework; +import planner.logic.command.CommandTest; import planner.logic.exceptions.legacy.ModException; import static org.junit.jupiter.api.Assertions.assertEquals; -public class PlannerTest extends CommandTestFramework { +public class PlannerTest extends CommandTest { private static final String LINE = "_______________________________";