예제 #1
0
 public void consumeTestLabeledBoolAsArray()
 {
     ArgDef testDef = new ArgDef();
     testDef.argLabels.Add("-t");
     testDef.type = typeof(bool);
     testDef.argCount = 1;
     testDef.createArrayForArgCount1 = true;
     testDef.parseInit(ArgTypeParser.basicParsers);
     VirtualArray<string> vArgs = new VirtualArray<string>(new string[] { "-t", "false" });
     ParsedArgs pArgs = new ParsedArgs();
     testDef.consume(vArgs, pArgs);
     Assert.IsTrue(pArgs.containsKey("t"), "[ArgDef][consume] consume should add a value to the passed in ParsedArgs when the appropriate args are given");
     bool[] result = pArgs.getArray<bool>("t");
     Assert.AreEqual<int>(1, result.Length, "[ArgDef][consume] consume should create an array of size 1 when argCount is 1 and createArrayForArgCount1 is true");
     Assert.IsFalse(result[0], "[ArgDef][consume] consume should set the appropriate value for the given arg name when encountered.");
 }
예제 #2
0
 public void consumeTestListOfString()
 {
     ArgDef testDef = new ArgDef();
     testDef.argLabels.Add("-t");
     testDef.argCount = 5;
     testDef.parseInit(ArgTypeParser.basicParsers);
     string[] testVals = new string[] { "ok", "", "what ", "yeyeah", "turn down" };
     VirtualArray<string> vArgs = new VirtualArray<string>(new string[] { "-t", testVals[0].ToString(), testVals[1].ToString(), testVals[2].ToString(), testVals[3].ToString(), testVals[4].ToString() });
     ParsedArgs pArgs = new ParsedArgs();
     testDef.consume(vArgs, pArgs);
     Assert.IsTrue(pArgs.containsKey("t"), "[ArgDef][consume] consume should add a value to the passed in ParsedArgs when the appropriate args are given");
     string[] result = pArgs.getArray<string>("t");
     int i = 0;
     foreach (string val in result)
     {
         Assert.AreEqual<string>(testVals[i], val, "[ArgDef][consume] consume resulted in an array with unexpected values.");
         i++;
     }
 }
예제 #3
0
 public void consumeTestRemainingString()
 {
     ArgDef testDef = new ArgDef();
     testDef.name = "t";
     testDef.argCountIsRemainderOfArgs = true;
     testDef.parseInit(ArgTypeParser.basicParsers);
     string[] testVals = new string[] { "what", "the", "french toast" };
     VirtualArray<string> vArgs = new VirtualArray<string>(new string[] { testVals[0].ToString(), testVals[1].ToString(), testVals[2].ToString() });
     ParsedArgs pArgs = new ParsedArgs();
     testDef.consume(vArgs, pArgs);
     Assert.IsTrue(pArgs.containsKey("t"), "[ArgDef][consume] consume should add a value to the passed in ParsedArgs when the appropriate args are given");
     string[] result = pArgs.getArray<string>("t");
     int i = 0;
     foreach (string val in result)
     {
         Assert.AreEqual<string>(testVals[i], val, "[ArgDef][consume] consume resulted in an array with unexpected values.");
         i++;
     }
 }
예제 #4
0
 public void consumeTestListOfDouble()
 {
     ArgDef testDef = new ArgDef();
     testDef.argLabels.Add("-t");
     testDef.type = typeof(double);
     testDef.argCount = 3;
     testDef.parseInit(ArgTypeParser.basicParsers);
     double[] testVals = new double[] { -234.556, 0, 234234.234 };
     VirtualArray<string> vArgs = new VirtualArray<string>(new string[] { "-t", testVals[0].ToString(), testVals[1].ToString(), testVals[2].ToString() });
     ParsedArgs pArgs = new ParsedArgs();
     testDef.consume(vArgs, pArgs);
     Assert.IsTrue(pArgs.containsKey("t"), "[ArgDef][consume] consume should add a value to the passed in ParsedArgs when the appropriate args are given");
     double[] result = pArgs.getArray<double>("t");
     int i = 0;
     foreach (double val in result)
     {
         Assert.AreEqual<double>(testVals[i], val, "[ArgDef][consume] consume resulted in an array with unexpected values.");
         i++;
     }
 }