Exemplo n.º 1
0
void testFollowSymbols()
{
    //using namespace test;

    Dummy dummy;
    Dummy::sfunc();
    Dummy::ONE;
    Dummy::PI;
    dummy.bla(fi);
    dummy.bla("bla");
    dummy.one = "one";
    Dummy::Internal internal;
    internal.one = "one";
    Dummy::INT i;
    Dummy::Values V;
    Dummy::v1;
    freefunc1();
    freefunc2(10);
    freefunc2("s");
    freefunc3(dummy);
    freefunc3(dummy, 10);
    freefunc3(10, 10);
    freefunc3(1.0);
    afunc();
    i;
    V;
}
Exemplo n.º 2
0
 void
 buildVector()
   {
     CHECK (0 == Dummy::checksum());
     {
       typedef typename Table<HO>::Type Vect;
       
       Vect table(50);
       CHECK (0 == Dummy::checksum());
       
       for (uint i=0; i<10; ++i)
         create_contained_object (table[i]);
       
       CHECK (0 < Dummy::checksum());
       CHECK ( table[9]);
       CHECK (!table[10]);
       
       Dummy *rawP = table[5].get();
       CHECK (rawP);
       CHECK (table[5]);
       CHECK (rawP == &(*table[5]));
       CHECK (rawP->acc(-555) == table[5]->acc(-555));
     }
     CHECK (0 == Dummy::checksum());
   }
Exemplo n.º 3
0
 void
 checkAllocation()
   {
     CHECK (0 == Dummy::checksum());
     {
       HO holder;
       CHECK (!holder);
       CHECK (0 == Dummy::checksum());
       
       create_contained_object (holder);
       CHECK (holder);
       CHECK (false != bool(holder));
       CHECK (bool(holder) != false);
       
       CHECK (0 < Dummy::checksum());
       CHECK ( &(*holder));
       CHECK (holder->acc(2) == 2 + Dummy::checksum());
       
       Dummy *rawP = holder.get();
       CHECK (rawP);
       CHECK (holder);
       CHECK (rawP == &(*holder));
       CHECK (rawP->acc(-5) == holder->acc(-5));
       
       TRACE (test, "holder at %p", &holder);
       TRACE (test, "object at %p", holder.get() );
       TRACE (test, "size(object) = %zu", sizeof(*holder));
       TRACE (test, "size(holder) = %zu", sizeof(holder));
     }
     CHECK (0 == Dummy::checksum());
   }
Exemplo n.º 4
0
int main () {
  Dummy a;
  Dummy* b = &a;
  if ( b->isitme(a) )
    cout << "yes, &a is b\n";
  return 0;
}
Exemplo n.º 5
0
int main1()
{
	Dummy a;
	Dummy* b = &a;
	if ( b->isitme(a) )
		cout << "yes, it's me, silly\n";
	return 0;
}
Exemplo n.º 6
0
int main()
{
  Dummy  dummy, dumbo;
  Dummy* pdummy = &dummy;

  printf("%s\n", pdummy->isitme(dummy) ? "true" : "false");
  printf("%s\n", pdummy->isitme(dumbo) ? "true" : "false");
}
Exemplo n.º 7
0
Arquivo: dummy.cpp Projeto: fkz/proof
Element* Dummy::_compare(Element*& _ele, std::vector< std::pair< Unknown*, Element* > >& unknwons)
{
    Function* appl = _ele->cast< Function > ();
    if (appl) {
        ForAll* forAll = _type->cast< ForAll > ();
        if (forAll) {
            Element *applVar = appl->getVar();
            Element *allVar = forAll->getVar();
            Element *allVar2 = allVar->compare(applVar, unknwons);
            allVar->remove();

            for (std::vector< std::pair< Unknown*, Element* > >::iterator it = unknwons.begin(); it != unknwons.end(); ++it) {
                Element* t = it->second->step(0);
                it->second->remove();
                it->second = t;
            }
            Element *applTerm = appl->getTerm();
            Element *allTerm = forAll->getTerm();
            Element *allTermDummy = new Dummy (allTerm);
            allTermDummy->copy();
            Element *allTermDummy2 = allTermDummy->compare(applTerm, unknwons);
            allTermDummy->remove();
            Element *error = new NamedVar<Error>(Error());
            error->copy();
            for (std::vector< std::pair< Unknown*, Element* > >::iterator it = unknwons.begin(); it != unknwons.end(); ++it) {
                Element* t = it->second->replace(error, 0);
                it->second->remove();;
                it->second = t;
            }

            error->remove();
            if (!(allTermDummy2 && allVar2))
                return 0;

            Element *allTermDummy2Type = allTermDummy2->cast<Dummy>()->type();

            Element* result = (new Dummy ((new ForAll (allVar2, allTermDummy2Type))->copy()))->copy();
            _ele = new Function (applVar, applTerm);
            _ele = _ele->copy();

            return result->copy();
        }
    }
    else {
        Element* _ele_type = _ele->type();
        Element* _type2 = _type->compare(_ele_type, unknwons);
        if (!_type2)
            return 0;
        for (std::vector< std::pair< Unknown*, Element* > >::iterator it = unknwons.begin(); it != unknwons.end(); ++it) {
            _ele = _ele->replaceNamed(it->second, Unknown::REPLACE_ELEMENT, it->first);
        }
        Dummy* result = new Dummy(_type2);
        return result->copy();
    }
}
Exemplo n.º 8
0
DataSet::DataSet(bool classAtStart, string file, double ratio)
{
  name = file;
  uniqueClasses=0;
  //int classC=0;
  classes = new vector<string>;
  data = new vector< vector<double>* >;
  ifstream ifs(file.c_str());
  if(!ifs.good())
    return;
  char buf[4096];
  string strBuf;
  string * tmpStr;
  while(!ifs.eof()){
    ifs.getline(buf,sizeof buf);
    strBuf = buf;
    if(strBuf.length()==0)
      break;
    if(classAtStart){
      if(!isIn(classes,*getNext(strBuf)))
	uniqueClasses++;
      classes->push_back(*getNext(strBuf));
      strBuf = getRest(strBuf);
    }else{
      if(!isIn(classes,*getLast(strBuf)))
	uniqueClasses++;
      classes->push_back(*getLast(strBuf));
      strBuf = getRestEnd(strBuf);
    }
    vector<double> * intvector = new vector<double>;
    while((tmpStr = getNext(strBuf)) != 0){
      intvector->push_back(atof(tmpStr->c_str()));
      strBuf = getRest(strBuf);
    }
    data->push_back(intvector);
  }
  ifs.close();
  cerr << "read "<<data->size()<<" datapoints, with "<<data->at(0)->size()<<" paramaters  classes: "<<classes->size()<<" unique:"<<uniqueClasses<<"\n";
  tests = (int)(data->size()*ratio);
  trainings = data->size()-tests;
  Dummy myDummy;
  int ** tmpCoord = myDummy.randomCoords(data->size(),0);
  trainCoords = new int [trainings];
  testCoords = new int [tests];
  int c = 0;
  for(;c<tests;c++)
    testCoords[c] = tmpCoord[c][0];
	
  for(;c<(tests+trainings);c++)
    trainCoords[(c-tests)] = tmpCoord[c][0];

  cerr << "tests: "<<tests<<" trainings: "<<trainings<<endl;
}
Exemplo n.º 9
0
int main ()
{
  Dummy master;
  printf("\nMaster before load :\n");
  master.print();
  printf("--------------------\n");
  load("load_test.bundle", "init", master);
  
  printf("Master after load   \n");
  master.print();
  printf("--------------------\n");
  
}
Exemplo n.º 10
0
/** float dummy::Dummy::addSomething(float value)
 * include/dummy/dummy.h:64
 */
static int Dummy_addSomething(lua_State *L) {
  try {
    Dummy *self = *((Dummy **)dub_checksdata(L, 1, "dummy.Dummy"));
    float value = dub_checknumber(L, 2);
    lua_pushnumber(L, self->addSomething(value));
    return 1;
  } catch (std::exception &e) {
    lua_pushfstring(L, "addSomething: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "addSomething: Unknown exception");
  }
  return dub_error(L);
}
Exemplo n.º 11
0
/** float dummy::Dummy::callback(const char *func, float value)
 * include/dummy/dummy.h:47
 */
static int Dummy_callback(lua_State *L) {
  try {
    Dummy *self = *((Dummy **)dub_checksdata(L, 1, "dummy.Dummy"));
    const char *func = dub_checkstring(L, 2);
    float value = dub_checknumber(L, 3);
    lua_pushnumber(L, self->callback(func, value));
    return 1;
  } catch (std::exception &e) {
    lua_pushfstring(L, "callback: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "callback: Unknown exception");
  }
  return dub_error(L);
}
Exemplo n.º 12
0
int main()
{
  Dumbo dumbo(0);
  Dumbo dumby = dumbo; // this produces a segfault at the end of main, because delete gets called twice on the same address
  dumby.set(100);
  printf("dumbo.get() returns %d\n", dumbo.get());
  printf("dumby.get() returns %d\n", dumby.get());

  Dummy dummy(0);
  Dummy dumpy = dummy; // this produces a segfault at the end of main, because delete gets called twice on the same address
  dumpy.set(100);
  printf("dummy.get() returns %d\n", dummy.get());
  printf("dumpy.get() returns %d\n", dumpy.get());
}
Exemplo n.º 13
0
void Unit::DirectionShow() const
{
    float power = m_MovePower.Length();
    Vec2 dir = m_MovePower / power;
    Vec2 temp = m_Pos;

    static Dummy dummy;
    auto length = static_cast<size_t>(power * m_Speed / m_MovePowerFrict / m_MovePowerLimit);
    for (size_t i = 0; i < length; ++i)
    {
        temp += dir;
        dummy.SetPos(temp);
        dummy.Render();
    }
}
Exemplo n.º 14
0
Arquivo: main.cpp Projeto: beng94/C11
int main()
{
    Dummy *d = new Dummy;
    Bucket *b = new Bucket();
    d->next = b;
    b->prev = d;

    for(int i = 2; i < 100; i++)
    {
        d->process(i);
    }

    delete d;

    return 0;
}
Exemplo n.º 15
0
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////

Dummy* ptr = 0;
Dummy* nullPointer = 0;
START_SECTION((PersistentObject()))
	ptr = new Dummy();
	TEST_NOT_EQUAL(ptr, nullPointer)
END_SECTION

START_SECTION((~PersistentObject()))
	delete ptr;
END_SECTION

START_SECTION((const UID& getPersistenceId() const))
  Dummy tmp;
  TEST_EQUAL(tmp.getPersistenceId(),0)
END_SECTION

START_SECTION((void setPersistenceId(const UID& persistence_id)))
  Dummy tmp;
  tmp.setPersistenceId(4711);
  TEST_EQUAL(tmp.getPersistenceId(),4711)
END_SECTION

START_SECTION((void clearId(bool deep = true)))
  Dummy tmp;
  tmp.setPersistenceId(4711);
  tmp.clearId(false);
  TEST_EQUAL(tmp.getPersistenceId(),0)
  TEST_EQUAL(tmp.subobjectsClear(),false)
Exemplo n.º 16
0
 // copy constructor:
 Dummy(Dummy& dummy) : pint(new int(dummy.get())) {}
#ifdef _WINDOWS
#include <ciso646>
#endif
#include <catch/catch.hpp>
#include "dummy.h"

using CppTemplate::Dummy;

namespace {

TEST_CASE("A newly created default dummy", "[creation]")
{
      Dummy dummy{};
      REQUIRE(dummy.speechless());
}

TEST_CASE("A english dummy", "[creation]")
{
      Dummy dummy{"Hello", "World"};

      REQUIRE(not dummy.speechless());
      REQUIRE(dummy.say_hello() == "Hello World");
}

} //namespace
Exemplo n.º 18
0
int main()
{





	// Create the main window
	sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");

	// Create a graphical text to display
	sf::Font font;
	if (!font.loadFromFile("arial.ttf"))
		return EXIT_FAILURE;


	Dummy *dummy = new Dummy(font);

	InputManager::Initialize();
	GUIManager::Initialize();
	ActionManager::Initialize();
	InputManager::SetDefaultActionMapping();


	ActionManager::MapActionToFunctionDown(ActionTypes::MoveLeft, std::bind(&Dummy::print1, dummy));
	ActionManager::MapActionToFunctionUp(ActionTypes::MoveLeft, std::bind(&Dummy::print2, dummy));

	ActionManager::MapActionToFunctionDown(ActionTypes::MoveRight, std::bind(&Dummy::print1, dummy));
	ActionManager::MapActionToFunctionUp(ActionTypes::MoveRight, std::bind(&Dummy::print2, dummy));



	InputManager::BindKeyToAction(ActionTypes::MoveLeft);
	InputManager::BindKeyToAction(ActionTypes::MoveRight);






	Button *button = GUIManager::MakeButton("left", 100,100, 100,25);
	ActionManager::MapWidgetToAction(ActionTypes::MoveLeft, button);

	// Button *toggle_button = GUIManager::MakeToggleButton("world!", 210,100,100,25);
	// toggle_button->SetCallback(std::function<void ()>(call_me));

	CheckButton *check_button = GUIManager::MakeCheckButton("I'm a toggle!", 100,135);
	ActionManager::MapWidgetToAction(ActionTypes::MoveRight, check_button);

	// Start the game loop
	while (window.isOpen())
	{
		// Process events
		sf::Event event;
		while (window.pollEvent(event))
		{
			// Close window: exit
			if (event.type == sf::Event::Closed)
				window.close();
			
			if(!GUIManager::ProcessInput(event))
				InputManager::ProcessInput(event);

		}
		// Clear screen
		window.clear();


		dummy->Draw(window);
		GUIManager::Draw(window);

		// Update the window
		window.display();
	}



	delete dummy;

	GUIManager::Finalize();

	return EXIT_SUCCESS;
}
Exemplo n.º 19
0
bool operator==(const Dummy & _d1, const Dummy & _d2)
{
  return _d1.fitness() == _d2.fitness();
}
Exemplo n.º 20
0
int main (int argc, char **argv)
{
	Dummy device (argc, argv);
	return device.run ();
}