diff --git a/src/test/cli_argument_parser.cpp b/src/test/cli_argument_parser.cpp index 15739f3..94c71ff 100644 --- a/src/test/cli_argument_parser.cpp +++ b/src/test/cli_argument_parser.cpp @@ -152,6 +152,37 @@ int main(int argc, char* argv[]) { delete[] validTestParameterList; std::cout << "Passed valid input test." << std::endl; + // empty input (valid and invalid) ################################# + std::vector emptyTestFlags; + + std::vector emptyTestUnpositionalArguments; + + std::vector emptyTestPositionalArguments; + + const char** emptyTestParameterList = new const char*[1]; + // The command is always a part of a command line, even if it is empty + // otherwise. Therefore, I think it is reasonable to assume that it + // will always be available. + emptyTestParameterList[0] = "test"; + int emptyTestParameterCount = 1; + + // valid + CLI::ArgumentsParser validEmptyTestParameterParser = CLI::ArgumentsParser(emptyTestParameterCount, emptyTestParameterList, emptyTestFlags, emptyTestUnpositionalArguments, emptyTestPositionalArguments); + ASSERT(!validEmptyTestParameterParser.wrongUsage); + ASSERT(validEmptyTestParameterParser.programName == std::string("test")); + + //invalid + emptyTestPositionalArguments.push_back(CLI::PositionalArgument("argument", "positional argument")); + + CLI::ArgumentsParser invalidEmptyTestParameterParser = CLI::ArgumentsParser(emptyTestParameterCount, emptyTestParameterList, emptyTestFlags, emptyTestUnpositionalArguments, emptyTestPositionalArguments); + ASSERT(invalidEmptyTestParameterParser.wrongUsage); + ASSERT(invalidEmptyTestParameterParser.programName == std::string("test")); + ASSERT(invalidEmptyTestParameterParser.getPositionalArgument(0).isError); + ASSERT(invalidEmptyTestParameterParser.getPositionalArgument(0).errorCode == ErrorCodes::NOT_PRESENT); + + delete[] emptyTestParameterList; + std::cout << "Passed empty input test." << std::endl; + //TODO add tests for invalid input std::cerr << "TODO: invalid input tests" << std::endl;