int main(int argc, char *argv[])
{
  Test::Output *pout;
  TestType tt(testTypeCompiler);
  int rtn(EXIT_SUCCESS);

  // if user passed command line argument then parse it
  if (argc==1)
  {
    tt=testTypeCompiler;
  }
  else if (argc==2)
  {
    size_t lenargv(strlen(argv[1]));

    // using short codes
    if (lenargv==2)
    {
      if (argv[1][0]=='-')
      {
        switch(argv[1][1])
        {
          case('t'):
            tt=testTypeText;
            break;
          case('c'):
            tt=testTypeCompiler;
            break;
          case('h'):
            tt=testTypeHTML;
            break;
          default:
            std::cerr << "Unrecognized parameter: " << argv[1] << std::endl;
            rtn=EXIT_FAILURE;
            break;
        }
      }
      else
      {
        std::cerr << "Unrecognized parameter: " << argv[1] << std::endl;
        rtn=EXIT_FAILURE;
      }
    }
    else
    {
      if (lenargv==6)
      {
        if (std::strncmp(argv[1], "--text", lenargv)==0)
          tt=testTypeText;
        else if (std::strncmp(argv[1], "--html", lenargv)==0)
          tt=testTypeHTML;
        else if (std::strncmp(argv[1], "--help", lenargv)==0)
          rtn=EXIT_FAILURE;
        else
        {
          std::cerr << "Unrecognized parameter: " << argv[1] << std::endl;
          rtn=EXIT_FAILURE;
        }
      }
      else if (lenargv==10)
      {
        if (std::strncmp(argv[1], "--compiler", lenargv)==0)
          tt=testTypeCompiler;
        else
        {
          std::cerr << "Unrecognized parameter: " << argv[1] << std::endl;
          rtn=EXIT_FAILURE;
        }
      }
    }
  }
  else
  {
    std::cerr << "Can only pass one argument." << std::endl;
    rtn=EXIT_FAILURE;
  }
  if (rtn==EXIT_FAILURE)
  {
    std::cerr << "  Usage: " << argv[0] << " [--text|-t|--compiler|-c|--html|-h]" << std::endl;
    return rtn;
  }

  // allocate the correct output type
  switch (tt)
  {
    case(testTypeText):
    {
      Test::TextOutput *po = new Test::TextOutput(Test::TextOutput::Verbose);
      pout = static_cast<Test::Output *>(po);
      break;
    }
    case(testTypeCompiler):
    {
      Test::CompilerOutput *po = new Test::CompilerOutput(Test::CompilerOutput::GCC);
      pout = static_cast<Test::Output *>(po);
      break;
    }
    case(testTypeHTML):
    {
      Test::HtmlOutput *po = new Test::HtmlOutput;
      pout = static_cast<Test::Output *>(po);
      break;
    }
    default:
    {
      rtn=EXIT_FAILURE;
      break;
    }
  }

  if (rtn == EXIT_SUCCESS)
  {
    // get the current time information
    time_t rawtime;
    struct tm * timeinfo;
    std::string datetime;
    time (&rawtime);
    timeinfo = localtime(&rawtime);
    datetime = asctime(timeinfo);

    // add the test suites to the test runner
    // NOTE: This is where changes should be needed
    //
    Test::Suite ts;
    std::string ostr_filename("piecewise_airfoil_test_results.html");

    // add the cppack test suites
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_four_digit_creator_test_suite<float>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_four_digit_creator_test_suite<double>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_four_digit_creator_test_suite<long double>()));

    //
    // NOTE: End of section that should be changed

    // run the test
    rtn = (ts.run(*pout)) ? EXIT_SUCCESS : EXIT_FAILURE;

    // generate the html data if requested
    if (tt==testTypeHTML)
    {
      std::ofstream ostr(ostr_filename.c_str());
      Test::HtmlOutput *phtmlout=dynamic_cast<Test::HtmlOutput *>(pout);

      phtmlout->generate(ostr, true, datetime);

      ostr.close();
    }

    delete pout;
  }

  return rtn;
}
示例#2
0
int main() {

	Interval x(Interval::EMPTY_SET);

    Test::TextOutput output(Test::TextOutput::Verbose);

    Test::Suite ts;

    ts.add(auto_ptr<Test::Suite>(new TestString()));
    ts.add(auto_ptr<Test::Suite>(new TestBitSet()));
    ts.add(auto_ptr<Test::Suite>(new TestSymbolMap()));
    ts.add(auto_ptr<Test::Suite>(new TestPixelMap()));

    ts.add(auto_ptr<Test::Suite>(new TestInterval()));
    ts.add(auto_ptr<Test::Suite>(new TestIntervalVector()));
    ts.add(auto_ptr<Test::Suite>(new TestIntervalMatrix()));
    ts.add(auto_ptr<Test::Suite>(new TestDim()));
    ts.add(auto_ptr<Test::Suite>(new TestArith()));
    ts.add(auto_ptr<Test::Suite>(new TestInnerArith()));
    //ts.add(auto_ptr<Test::Suite>(new TestDomain()));

    ts.add(auto_ptr<Test::Suite>(new TestAffine2()));

    ts.add(auto_ptr<Test::Suite>(new TestExpr()));
    ts.add(auto_ptr<Test::Suite>(new TestExprCopy()));
    ts.add(auto_ptr<Test::Suite>(new TestExprDiff()));
    ts.add(auto_ptr<Test::Suite>(new TestExprSplitOcc()));
    ts.add(auto_ptr<Test::Suite>(new TestFunction()));
    ts.add(auto_ptr<Test::Suite>(new TestNumConstraint()));
    ts.add(auto_ptr<Test::Suite>(new TestEval()));

    ts.add(auto_ptr<Test::Suite>(new TestParser()));
    ts.add(auto_ptr<Test::Suite>(new TestSystem()));

    ts.add(auto_ptr<Test::Suite>(new TestHC4Revise()));
    ts.add(auto_ptr<Test::Suite>(new TestInHC4Revise()));
    ts.add(auto_ptr<Test::Suite>(new TestGradient()));

    ts.add(auto_ptr<Test::Suite>(new TestLinear()));
    ts.add(auto_ptr<Test::Suite>(new TestNewton()));

    ts.add(auto_ptr<Test::Suite>(new TestPdcHansenFeasibility()));

    ts.add(auto_ptr<Test::Suite>(new TestCtcHC4()));
    ts.add(auto_ptr<Test::Suite>(new TestCtcInteger()));
    ts.add(auto_ptr<Test::Suite>(new TestCtcFwdBwd()));
    ts.add(auto_ptr<Test::Suite>(new TestCtcNotIn()));
    ts.add(auto_ptr<Test::Suite>(new TestCtcExist()));
    ts.add(auto_ptr<Test::Suite>(new TestCtcForAll()));
    ts.add(auto_ptr<Test::Suite>(new TestCtcPolytopeHull()));
    ts.add(auto_ptr<Test::Suite>(new TestCtcSegment()));
    ts.add(auto_ptr<Test::Suite>(new TestCtcPixelMap()));

    ts.add(auto_ptr<Test::Suite>(new TestFritzJohn()));

    ts.add(auto_ptr<Test::Suite>(new TestOptimizer()));
    ts.add(auto_ptr<Test::Suite>(new TestSeparator()));
    ts.add(auto_ptr<Test::Suite>(new TestSepPolygon()));



    return ts.run(output,false) ? EXIT_SUCCESS : EXIT_FAILURE;

}