Ejemplo n.º 1
0
static int premia_interactive_menu(  Planning          *pt_plan,
                                     Model             **models,
                                     Family            **families,
                                     Pricing           **pricings,
                                     int               user)
{

  Model*            pt_model;
  Option*           pt_option;
  Pricing*          pt_pricing;
  PricingMethod*    pt_method;
  DynamicTest*      pt_test;
  PricingMethod*    pt_methods_available[MAX_METHODS];

  if (OutputFile(&out_stream)!=OK) return WRONG;
  if (SelectModel(user,pt_plan,models,families,pricings,&pt_model)!=OK) return WRONG;
  if (SelectOption(user,pt_plan,families,pt_model,pricings,&pt_option)!=OK) return WRONG;
  if (SelectPricing(user,pt_model,pt_option,pricings,&pt_pricing)!=OK) return WRONG;

  while(1){
    if (SelectMethod(user,pt_plan,pt_pricing,pt_option,pt_model,&pt_method)!=OK)
      return FAIL;
    if (SelectTest(user,pt_plan,pt_pricing,pt_option,pt_model,pt_method,&pt_test)!=OK)
      return FAIL;
    if (GetTimeInfo(user,pt_plan,&computation_time_info)!=OK)
      return FAIL;
          
    if ((pt_plan->Action=='p')||
        (( pt_plan->Action=='t')&&
         (GetTest(user,pt_plan,pt_pricing,pt_option,pt_test)==OK))){
      (void)ShowPlanning(NAMEONLYTOFILE,pt_plan);
      (void)Action(pt_model,pt_option,pt_pricing,
                   pt_method,pt_test,NAMEONLYTOFILE,pt_plan,&computation_time_info);
      Fprintf(TOSCREEN,"\nComputing...\n");
      Iterate(pt_plan,&(pt_plan->Par[0]),0,pt_plan->Action,pt_model,pt_option,
              pt_pricing,pt_method,pt_test,TOFILE,&computation_time_info);
      pt_methods_available[pt_plan->NumberOfMethods]=pt_method;
      if (pt_plan->Action=='t' || MoreAction(&(pt_plan->NumberOfMethods))==FAIL)
        break;
      else
        free_premia_method(pt_method);
    }
  }

  fclose(out_stream);

  if ((pt_plan->Action=='p') && (pt_plan->VarNumber>0))
    (void)BuildGnuStuff(pt_plan,pt_model,pt_option,pt_pricing,pt_methods_available);

  if (pt_plan->Action=='t')
    {
      (void)FreeTest(pt_test); 
      (void)BuildGnuStuffTest(pt_model,pt_option,pt_pricing,pt_method,pt_test); 
    }
  free_premia_model(pt_model);
  free_premia_option(pt_option);
  free_premia_method(pt_method);
  return OK;
}
Ejemplo n.º 2
0
PhysicsTest* RenderTestSelector(const GLFontRenderer& texter, float x, float text_scale, int start_index, float& y_last)
{
	int NbTests = GetNbTests();
	const int NbToGo = ICE_ARRAYSIZE(Alpha);
	float y = float(NbToGo) * text_scale;

	const float XOffset = 0.01f;
//	DrawRectangle(XOffset, 1.0f-XOffset, y + text_scale*2.0f, y - text_scale*9.0f, Point(1.0f, 0.5f, 0.2f), 0.5f);

	PhysicsTest* CandidateTest = null;

	for(int i=0;i<NbToGo;i++)
	{
		const float a = Alpha[i];
		const bool Selected = a==1.0f;
		if(Selected)
			texter.setColor(1.0f, 0.5f, 0.2f, a);
		else
			texter.setColor(1.0f, 1.0f, 1.0f, a);

		const int RealIndex = start_index % NbTests;

		PhysicsTest* Test = GetTest(RealIndex);
		if(Test)
		{
			static const char* CategoryText[] = 
			{
				"(undefined)",
				"(API)",
				"(behavior)",
				"(contact generation)",
				"(performance)",
				"(raycast)",
				"(sweep)",
				"(overlap)",
				"(CCD)",
				"(static scene)",
			};

			const TestCategory TC = Test->GetCategory();
			if(Test->IsPrivate())
			{
				texter.print(x+XOffset, y, text_scale, _F("%d: %s - %s (PRIVATE)", RealIndex, CategoryText[TC], Test->GetName()));
			}
			else
			{
				texter.print(x+XOffset, y, text_scale, _F("%d: %s - %s", RealIndex, CategoryText[TC], Test->GetName()));
			}
		}

		if(Selected)
			CandidateTest = Test;

		y -= text_scale;
		start_index++;
	}
	y_last = y;
	return CandidateTest;
}
Ejemplo n.º 3
0
int main(int argc, char** argv)
{

  // Registry and test suite
  CppUnit::TestFactoryRegistry &registry = CppUnit::TestFactoryRegistry::getRegistry();
  CppUnit::TestSuite *testSuite = static_cast<CppUnit::TestSuite*>(registry.makeTest());

  if (argc == 3)
  {
    std::string arg = argv[1];
    if (strcmp(argv[1], "--cdash-prepare") == 0)
    {
       std::cout << "# this is a ctest input file" << std::endl;
       std::cout << "include(SiconosTestConfig.cmake)" << std::endl;

      CdashDump(testSuite, argv[2]);
    }
  }
  else if (argc == 2)
  {
    // The object to run tests
    CppUnit::TextUi::TestRunner runner;

    // get the test
    CppUnit::Test * test = GetTest(testSuite, argv[1]);

    if (test != NULL)
    {
      runner.addTest(test);

      bool wasSucessful = false;

      wasSucessful = runner.run("", false, true, false);
      return wasSucessful ? 0 : 1;
    }
    else
    {
      std::cerr << "Cannot find test : " << argv[1] << std::endl;
      return 1;
    }

  }

  else
  {
    std::cerr << "Error, no test given" << std::endl;
    return 1;
  }
}
Ejemplo n.º 4
0
static TestCategory GetCurrentCategory(int start_index)
{
	const udword NbTests = GetNbTests();
	const int NbToGo = ICE_ARRAYSIZE(Alpha);
	for(int i=0;i<NbToGo;i++)
	{
		const float a = Alpha[i];
		const bool Selected = a==1.0f;

		if(Selected)
		{
			const int RealIndex = start_index % NbTests;
			PhysicsTest* Test = GetTest(RealIndex);
			return Test->GetCategory();
		}
		start_index++;
	}
	return CATEGORY_UNDEFINED;
}
Ejemplo n.º 5
0
CppUnit::Test* GetTest(CppUnit::Test* tests, const std::string& name)
{

  CppUnit::TestSuite* testSuite = dynamic_cast<CppUnit::TestSuite *>(tests);

  CppUnit::Test* returnTest = NULL;

  if (testSuite)
  {
    if (testSuite->getName() == name)
    {
      return (testSuite);
    }
    else
    {
      std::vector<CppUnit::Test*> allTests = testSuite->getTests();
      std::vector<CppUnit::Test*>::iterator testi;
      for (testi = allTests.begin();
           testi != allTests.end();
           testi++)
      {
        returnTest = GetTest(*testi, name);
        if (returnTest)
          return (returnTest);
      }
    }
  }
  else
  {
    if (tests->getName() == name)
    {
      return (tests);
    }
  }
  return NULL;
}
Ejemplo n.º 6
0
int main(int argc, char** argv) {

    // add all tests
    AddTest(new CamerasTest::CamerasTest);
    AddTest(new ConnectionsTest::ConnectionsTest);
    AddTest(new DisplayTest::DisplayTest);
    AddTest(new EventBindingsTest::EventBindingsTest);
    AddTest(new EventsTest::EventsTest);
    AddTest(new FollowPathTest::FollowPathTest);
    AddTest(new GuiTest::GuiTest);
    AddTest(new InputTest::InputTest);
    AddTest(new LoggerTest::LoggerTest);
    AddTest(new MouseCursorTest::MouseCursorTest);
    AddTest(new MusicFadeTest::MusicFadeTest);
    AddTest(new MusicTest::MusicTest);
    AddTest(new NamesTest::NamesTest);
    AddTest(new NetworkTest::NetworkTest);
    AddTest(new ParticlesTest::ParticlesTest);
    AddTest(new PhysicsSimpleTest::PhysicsSimpleTest);
    AddTest(new PhysicsStressTest::PhysicsStressTest);
    AddTest(new PrimitivesTest::PrimitivesTest);
    AddTest(new QObjectTest::QObjectTest);
    AddTest(new RandomTest::RandomTest);
    AddTest(new ResourceManagerTest::ResourceManagerTest);
    AddTest(new ScriptComponentTest::ScriptComponentTest);
    AddTest(new ScriptingTest::ScriptingTest);
    AddTest(new ShadowsTest::ShadowsTest);
    AddTest(new SignalsTest::SignalsTest);
    AddTest(new SoundTest::SoundTest);
    AddTest(new StatesTest::StatesTest);
    AddTest(new TextTest::TextTest);
    AddTest(new TimerTest::TimerTest);
    AddTest(new TerrainTest::TerrainTest);

    if(argc < 2) {
        std::cout << "TestFramework usage: " << std::endl;
        std::cout << "  ./TestFramework <test name>" << std::endl;
        std::cout << std::endl << "Available tests:" << std::endl;
        for(auto iter = Tests.begin(); iter != Tests.end(); ++iter) {
            std::cout << "  - " << dt::Utils::ToStdString(iter->first) << std::endl;
        }
    } else {
        bool failure = false;

        for(int i = 1; i < argc; ++i) {
            QString name(argv[i]);
            if(name == "client" || name == "server") // ignore parameters of network
                continue;
            std::cout << "Running test " + dt::Utils::ToStdString(name) + "..." << std::endl;
            Test* test = GetTest(name);
            if(test == nullptr) {
                std::cerr << "Test " + dt::Utils::ToStdString(name) + " not found. Skipping." << std::endl;
            } else if(!test->Run(argc, argv)) {
                failure = true;
                std::cerr << "Test " + dt::Utils::ToStdString(name) + " FAILED." << std::endl;
            } else {
                std::cout << "Test " + dt::Utils::ToStdString(name) + ": OK." << std::endl;
            }
        }

        if(failure) {
            std::cerr << std::endl << "Not all tests successful, check log for details." << std::endl;
            return 1;
        }
    }
    return 0;
}