Пример #1
0
 public void consumeTestFlag()
 {
     ArgDef testDef = new ArgDef();
     testDef.argLabels.Add("-t");
     testDef.parseInit(ArgTypeParser.basicParsers);
     VirtualArray<string> vArgs = new VirtualArray<string>(new string[] { "-t" });
     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");
     Assert.IsTrue(pArgs.getValue<bool>("t"), "[ArgDef][consume] consume should set the appropriate value for the given arg name when encountered.");
 }
Пример #2
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.");
 }
Пример #3
0
 public void consumeTestLabeledDouble()
 {
     ArgDef testDef = new ArgDef();
     testDef.argLabels.Add("-t");
     testDef.type = typeof(double);
     testDef.argCount = 1;
     testDef.parseInit(ArgTypeParser.basicParsers);
     VirtualArray<string> vArgs = new VirtualArray<string>(new string[] { "-t", "33.3" });
     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");
     Assert.AreEqual(33.3, pArgs.getValue<double>("t"), 0.01, "[ArgDef][consume] consume should add a value to the passed in ParsedArgs when the appropriate args are given");
 }
Пример #4
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++;
     }
 }
Пример #5
0
 public void consumeTestOrderedInt()
 {
     ArgDef testDef = new ArgDef();
     testDef.name = "test";
     testDef.type = typeof(int);
     testDef.parseInit(ArgTypeParser.basicParsers);
     VirtualArray<string> vArgs = new VirtualArray<string>(new string[] { "33" });
     ParsedArgs pArgs = new ParsedArgs();
     testDef.consume(vArgs, pArgs);
     Assert.IsTrue(pArgs.containsKey("test"), "[ArgDef][consume] consume should add a value to the passed in ParsedArgs when the appropriate args are given");
     Assert.AreEqual<int>(33, pArgs.getValue<int>("test"), "[ArgDef][consume] consume should set the appropriate value for the given arg name when encountered.");
 }
Пример #6
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++;
     }
 }
Пример #7
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++;
     }
 }