public void consumeTestOrderedEncounteredWrongType() { ArgDef testDef = new ArgDef(); testDef.name = "test"; testDef.type = typeof(int); testDef.parseInit(ArgTypeParser.basicParsers); VirtualArray<string> vArgs = new VirtualArray<string>(new string[] { "a" }, 0, 1); ParsedArgs pArgs = new ParsedArgs(); bool result = testDef.consume(vArgs, pArgs); bool errors = testDef.errorOccured(); Assert.IsFalse(result, "[ArgDef][consume] consume should return false when the args provided don't match the arg def's type."); Assert.IsTrue(errors, "[ArgDef][consume] consume should generate an error when the args provided don't match the arg def's type."); }
public void consumeTestWrongNumberOfFollowingArgs() { ArgDef testDef = new ArgDef(); testDef.argLabels.Add("-test"); testDef.argCount = 2; testDef.parseInit(ArgTypeParser.basicParsers); VirtualArray<string> vArgs = new VirtualArray<string>(new string[] { "-test", "a" }, 0, 2); ParsedArgs pArgs = new ParsedArgs(); bool result = testDef.consume(vArgs, pArgs); bool errors = testDef.errorOccured(); Assert.IsFalse(result, "[ArgDef][consume] consume should return false when there are less remaining args than argCount."); Assert.IsTrue(errors, "[ArgDef][consume] consume should generate an error message when there are less remaining args than argCount."); }
public void consumeTestMultipleOptionEncounters() { ArgDef testDef = new ArgDef(); testDef.argLabels.AddRange(new string[]{"-test", "-t"}); testDef.parseInit(ArgTypeParser.basicParsers); VirtualArray<string> vArgs = new VirtualArray<string>(new string[] {"-test", "-t"}, 0, 2); ParsedArgs pArgs = new ParsedArgs(); testDef.consume(vArgs, pArgs); bool result2 = testDef.consume(vArgs, pArgs); bool errors = testDef.errorOccured(); Assert.IsFalse(result2, "[ArgDef][consume] consume should return false when a label is encountered twice."); Assert.IsTrue(errors, "[ArgDef][consume] consume should generate an error message when a label is encountered twice."); }