bool StringTests::correctTest() { string param1 = "abcdefgh"; ArgList args1; args1.push("program").push("-s").push(param1.c_str()); string param2 = "!@#$%^&*()_+"; ArgList args2; args2.push("program").push("-s").push(param2.c_str()); FrontEnd arglib; StringType stringType = StringType(); arglib.addOption("s", OPTION_ALLOWED, stringType, PARAM_REQUIRED); args1.dump(cout); args2.dump(cout); bool firstParseWithoutException = Tests::parseMustNotThrow(arglib, args1); bool isParam1OK = (param1 == arglib.getOptionParameter<string>("s")); bool secondParseWithoutException = Tests::parseMustNotThrow(arglib, args2); bool isParam2OK = (param2 == arglib.getOptionParameter<string>("s")); return firstParseWithoutException && secondParseWithoutException && isParam1OK && isParam2OK; }
bool BoolTests::trueFalseTest(){ ArgList args; args.push("program").push("-t").push("true"); args.push("--false").push("false"); FrontEnd arglib; BoolType boolType = BoolType(); arglib.addOption("t", OPTION_ALLOWED, boolType, PARAM_REQUIRED); arglib.addOption("false", OPTION_ALLOWED, boolType, PARAM_ALLOWED); args.dump(cout); return Tests::parseMustNotThrow(arglib, args)&& arglib.getOptionParameter<bool>("t") == true && arglib.getOptionParameter<bool>("false") == false; }
bool BoolTests::badInputTest(){ ArgList args; args.push("program").push("-t").push("abcd"); FrontEnd arglib; BoolType boolType = BoolType(); arglib.addOption("t", OPTION_ALLOWED, boolType, PARAM_REQUIRED); args.dump(cout); return Tests::parseMustThrow(arglib, args); }
bool BoolTests::noInputTest(){ ArgList args; args.push("program").push("--false"); FrontEnd arglib; BoolType boolType = BoolType(); string optionName = "false"; arglib.addOption(optionName, OPTION_ALLOWED, boolType, PARAM_ALLOWED); args.dump(cout); return Tests::parseMustNotThrow(arglib, args)&& Tests::getOptionValueMustThrow<bool>(arglib, "false"); }