From: Justin Cinkelj <justin.cink...@xlab.si>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

command line: add tests for empty commandline string parsing

Signed-off-by: Justin Cinkelj <justin.cink...@xlab.si>
Message-Id: <20170913120516.17024-6-justin.cink...@xlab.si>

---
diff --git a/tests/tst-commands.cc b/tests/tst-commands.cc
--- a/tests/tst-commands.cc
+++ b/tests/tst-commands.cc
@@ -22,6 +22,60 @@ static void report(bool ok, const char* msg)
     printf("%s: %s\n", (ok ? "PASS" : "FAIL"), msg);
 }

+static bool test_parse_empty()
+{
+    std::vector<std::vector<std::string> > result;
+    bool ok;
+
+    result = osv::parse_command_line(std::string(""), ok);
+
+    if (!ok) {
+        return false;
+    }
+
+    if (result.size() != 0) {
+        return false;
+    }
+
+    return true;
+}
+
+static bool test_parse_space()
+{
+    std::vector<std::vector<std::string> > result;
+    bool ok;
+
+    result = osv::parse_command_line(std::string(" "), ok);
+
+    if (!ok) {
+        return false;
+    }
+
+    if (result.size() != 0) {
+        return false;
+    }
+
+    return true;
+}
+
+static bool test_parse_spaces()
+{
+    std::vector<std::vector<std::string> > result;
+    bool ok;
+
+    result = osv::parse_command_line(std::string(" \t\n;"), ok);
+
+    if (!ok) {
+        return false;
+    }
+
+    if (result.size() != 0) {
+        return false;
+    }
+
+    return true;
+}
+
 static bool test_parse_simplest()
 {
     std::vector<std::vector<std::string> > result;
@@ -1088,6 +1142,9 @@ int main(int argc, char *argv[])
 {
     all_test_loader_parse_cmdline();

+    report(test_parse_empty(), "empty string");
+    report(test_parse_space(), "single space");
+    report(test_parse_spaces(), "multiple diffrent whitespaces");
     report(test_parse_simplest(), "simplest command line");
report(test_parse_simplest_with_args(), "simplest command line with args");
     report(test_parse_simplest_with_quotes(),

--
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to