fix some invalid inputs
Change-Id: I9302c52d7ed0142eb1b867ace101b41d41b05e2d
diff --git a/tests/cd.cpp b/tests/cd.cpp
index 9c73c61..d6079fb 100644
--- a/tests/cd.cpp
+++ b/tests/cd.cpp
@@ -91,11 +91,39 @@
}
}
+
+ SECTION("whitespace handling")
+ {
+ SECTION(" cd a ")
+ {
+ input = " cd a ";
+ expected.m_path.m_nodes.push_back(container_("a"));
+ }
+ }
+
cd_ command = parser.parseCommand(input, errorStream);
REQUIRE(command == expected);
}
SECTION("invalid input")
{
+ SECTION("missing space between a command and its arguments")
+ {
+ SECTION("cda")
+ {
+ input = "cda";
+ }
+ }
+ SECTION("garbage arguments handling")
+ {
+ SECTION("cd a garbage")
+ {
+ input = "cd a garbage";
+ }
+ SECTION("cd a/a2 garbage")
+ {
+ input = "cd a/a2 garbage";
+ }
+ }
SECTION("invalid identifiers")
{
SECTION("nonexistent")
@@ -108,8 +136,19 @@
input = "cd nonexistent/lol";
}
}
+
SECTION("invalid list key identifiers")
{
+ SECTION("list")
+ {
+ input = "cd list";
+ }
+
+ SECTION("list[]")
+ {
+ input = "cd list[]";
+ }
+
SECTION("twoKeyList[invalidKey=4]")
{
input = "cd twoKeyList[invalidKey=4]";