예제 #1
0
int main(int argc, char *argv[])
{
    testArray();
    testPlugin();
    testList();
    return 0;
    testByteArray();
    testHash();
    testImage();
    testIO();
    testMap();
    testString();
    testStringList();
    testStruct();
    testThreads();
    testVariant1();
    testVariant2();
    testVariant3();
    testVector();
    testVectorOfList();

    testObject(argc, argv);

    QColor color(255,128,10);
    QFont font;

    while(true)
        ;

    return 0;
}
예제 #2
0
파일: main.cpp 프로젝트: michalkuraz/hermes
int main() {
	int ret = 0;

	// test JudyV
	if ((ret = testJudyArray()) != 0)
		return ret;

	if ((ret = testJudyArrayPtrStruct()) != 0)
		return ret;

	// test Map
	if ((ret = testMap()) != 0)
		return ret;

	// test MapHS
	if ((ret = testMapHS()) != 0)
		return ret;

	// test MapHSOrd
	if ((ret = testMapHSOrd()) != 0)
		return ret;

	// test Judy1
	if ((ret = testBitJudyArray()) != 0)
		return ret;

	return ret;
}
예제 #3
0
void webMain()
{
	testMap();
	testMultiMap();
	testUnorderedMap();
	testPointerMap();
	testUnorderedMapOrPointers();
}
예제 #4
0
int Test::run(){
    int error = 0;
    unsigned int size = 20;

    Map testMap("testMap.map", size,size);

    if(testMap.getMapContent().size() != size) error++;

    for(int y = 0; y < testMap.height; y++){
        for(int x = 0; x < testMap.width; x++){
            if(testMap.getMapContent()[y].size() != size) error++;
            if(testMap.getMapObject(y,x) != 0) error++;
            testMap.setMapObject(1,y,x);
        }
    }

    for(int y = 0; y < testMap.height; y++){
        for(int x = 0; x < testMap.width; x++){
            if(testMap.getMapObject(y,x) != 1) error++;
        }
    }

    testMap.setMapObject(0,size - 5, size - 2);
    if(testMap.getMapObject(size - 5,size - 2) != 0) error++;

    testMap.setMapObject(1,size - size,size - size);
    if(testMap.getMapObject(size - size,size -size) != 1) error++;

    testMap.setMapObject(1,size - 1,size - (size - 1));
    if(testMap.getMapObject(size - 1,size - (size - 1)) != 1) error++;

    testMap.setMapObject(0,size - 1,size - 1);
    if(testMap.getMapObject(size - 1,size - 1) != 0) error++;

    for(int y = 0; y < testMap.height; y++){
        for(int x = 0; x < testMap.width; x++){
            testMap.setMapObject(0,y,x);
        }
    }

    testMap.saveMap();

    testMap.setMapObject(3,6,2);
    testMap.setMapObject(1,9,1);

    SimulateMap testSim(&testMap);

    testSim.setScanPoint(6,2);
    testSim.simulate();
    Pointcloud pC = testSim.getPointCloud();
    for(Pointcloud::Point p : pC.getPoints()){
        if(p.X != -1) error++;
        if(p.Y != -3) error++;
    }
    return error;
}
예제 #5
0
int main()
{
    srand(time(0));
    if(!testSet())
        return 1;
    if(!testMap())
        return 1;
    cout<<"LockHashMap test succ\n";
    return 0;
}
int
main (int argc, char *argv[])
{
  int failureCount = 0;
  int i;

  GNUNET_log_setup ("test-container-multipeermap", "WARNING", NULL);
  for (i = 1; i < 255; i++)
    failureCount += testMap (i);
  if (failureCount != 0)
    return 1;
  return 0;
}
예제 #7
0
void testHashMapStd(int iterations)
{
  srand(100);
  std::unordered_map<int, int> testMap(1000);
  for (int i = 0; i < iterations; ++i)
  {
    testMap.insert(std::make_pair(rand() % 1000, 0));
  }
  for (int i = 0; i < iterations; ++i)
  {
    testMap.insert(std::make_pair(rand() % 1000, 0));
    testMap.erase(rand() % 1000);
  }
  for (int i = 0; i < iterations; ++i)
  {
    testMap.erase(rand() % 1000);
  }
}
예제 #8
0
void main()
{
    try
    {
        testVector();
        testVectorWithTypedef();
        testMap();

        std::cout << "\n\nFinished\n\n";
    }
    catch (std::exception & e)
    {
        std::cout << "\n\nException - " << e.what() << "\n\n";
    }
    catch (...)
    {
        std::cout << "\n\nUnhandled exception\n\n";
    }
}
예제 #9
0
  void TypeTestNode::gen() {
    // generates n-way type test; fall-through code is "unknown" case
    BasicNode::gen();
    r = genHelper->moveToReg(_src, Temp3);
    fint smiIndex = 0;
    fint floatIndex = 0;
         if (maps->nth(0) == Memory->smi_map  ->enclosing_mapOop()) smiIndex   = 1;
    else if (maps->nth(0) == Memory->float_map->enclosing_mapOop()) floatIndex = 1;
    if (maps->length() > 1) {
           if (maps->nth(1) == Memory->smi_map  ->enclosing_mapOop()) smiIndex   = 2;
      else if (maps->nth(1) == Memory->float_map->enclosing_mapOop()) floatIndex = 2;
    }
    fint nconstants = 0;
    fint ntests = maps->length();
    fint firstMem = max(smiIndex, floatIndex);
    bool immediateOnly = firstMem == maps->length();
    fint i;
    for (i = firstMem; i < ntests; i++) {
      ConstPReg* pr = mapPRs->nth(i);
      if (!pr->constant->is_map()) nconstants++;
    }

    if (SICCountTypeTests) {
      theAssembler->startTypeTest(ntests, false, immediateOnly);
    }

    // first test against all constants
    if (!hasUnknown && nconstants == ntests) {
      // don't need to check for last constant
      ntests--;
    }
    for (i = firstMem; i < ntests; i++) {
      ConstPReg* pr = mapPRs->nth(i);
      if (!pr->constant->is_map()) testOop(pr, i + 1);
    }

    if (!hasUnknown && nconstants >= ntests) {
      // last case; should omit branch
      if (SICCountTypeTests) {
        theAssembler->endTypeTest();
      } else {
        theAssembler->Nop();    // fill delay slot of last test
      }
      define(ntests + 1, theAssembler->BraForward(true));
      return;           // done -- tested all constants
    }
    

    Label* firstMemOopTest = NULL;
    fint n = prologue(theAssembler, r, smiIndex, floatIndex, immediateOnly,
                      firstMemOopTest);

    if (n) define(n, theAssembler->BraForward(true));
    if (firstMemOopTest) {
      if (immediateOnly) {
        define(0, firstMemOopTest);     // no memOop tests
      } else {
        firstMemOopTest->define();
      }
    }
    if (!hasUnknown) ntests--;      // all maps known, can omit last test
    // test against all maps
    for (i = firstMem; i < ntests; i++) {
      ConstPReg* pr = mapPRs->nth(i);
      if (pr->constant->is_map()) testMap(pr, i + 1);
    }
    if (!immediateOnly) theAssembler->Nop();// fill delay slot of last map test
    if (SICCountTypeTests) theAssembler->endTypeTest();
    if (!hasUnknown) {
      // last case; should omit branch
      define(ntests + 1, theAssembler->BraForward(true));
    }
  }
예제 #10
0
int Test::run(){
    std::cout << "Enviroment Simulator test begin" << std::endl;
    int error = 0;
    int size = 20;

    std::ofstream testResultsFile;
    testResultsFile.open("testResult.txt");
    if(!testResultsFile.is_open()){
        testResultsFile << "Error: ";
        std::cout << "Result log: " << "Log file could not be opend" << std::endl;
        ++error;
    }

    testResultsFile << "Enviroment Simulator test begin" << std::endl;

    //Map not from file
    testResultsFile << "Enviroment Simulator test Map not from file" << std::endl;
    Map testMap("testMap.map", size,size);

    if(testMap.height != size || testMap.width != size){
        testResultsFile << "Error: ";
        testResultsFile << "Map not from file: " << "Map y size incorret" << std::endl;
        ++error;
    }

    if(testMap.height != size || testMap.width != size){
        testResultsFile << "Error: ";
        testResultsFile << "Map not from file: " << "Map x size incorret" << std::endl;
        ++error;
    }

    for(int y = 0; y < testMap.height; y++){
        for(int x = 0; x < testMap.width; x++){
            if(testMap.getMapObject(y,x) != 0){
                testResultsFile << "Error: ";
                testResultsFile << "Map not from file: " << "Conntent error. != 0" << std::endl;
                ++error;
            }
            testMap.setMapObject(1,y,x);
        }
    }

    for(int y = 0; y < testMap.height; y++){
        for(int x = 0; x < testMap.width; x++){
            if(testMap.getMapObject(y,x) != 1){
                testResultsFile << "Error: ";
                testResultsFile << "Map not from file: " << "Conntent error. != 1" << std::endl;
                ++error;
            }
        }
    }


    testMap.setMapObject(0,size - 5,size - 2);
    if(testMap.getMapObject(size - 5,size - 2) != 0){
        testResultsFile << "Error: ";
        testResultsFile << "Map not from file: " << "Object error size - 5,size - 2 != 0" << std::endl;
        ++error;
    }

    testMap.setMapObject(1,size - size,size - size);
    if(testMap.getMapObject(size - size,size -size) != 1){
        testResultsFile << "Error: ";
        testResultsFile << "Map not from file: " << "Object error 0,0 != 1" << std::endl;
        ++error;
    }

    testMap.setMapObject(1,size - 1,size - (size - 1));
    if(testMap.getMapObject(size - 1,size - (size - 1)) != 1){
        testResultsFile << "Error: ";
        testResultsFile << "Map not from file: " << "Object error size - 1,size - (size - 1) != 1" << std::endl;
        ++error;
    }

    testMap.setMapObject(0,size - 1,size - 1);
    if(testMap.getMapObject(size - 1,size - 1) != 0){
        testResultsFile << "Error: ";
        testResultsFile << "Map not from file: " << "Object error size - 1,size - (size - 1) != 0" << std::endl;
        ++error;
    }

    testMap.setMapObject(0,size + 1,size + 1);
    if(testMap.getMapObject(size + 1,size + 1) != -1){
        testResultsFile << "Error: ";
        testResultsFile << "Map not from file: " << "Object error size - 1,size - (size - 1) != -1" << std::endl;
        ++error;
    }

    testMap.setMapObject(0,size,size);
    if(testMap.getMapObject(size,size) != -1){
        testResultsFile << "Error: ";
        testResultsFile << "Map not from file: " << "Object error size, size != -1" << std::endl;
        ++error;
    }

    testMap.setMapObject(0,size - 21,size - 21);
    if(testMap.getMapObject(size - 21,size - 21) != -1){
        testResultsFile << "Error: ";
        testResultsFile << "Map not from file: " << "Object error size - 21,size - 21 + 1 != 1" << std::endl;
        ++error;
    }

    for(int y = 0; y < testMap.height; y++){
        for(int x = 0; x < testMap.width; x++){
            testMap.setMapObject(0,y,x);
        }
    }

    //Save file
    testResultsFile << "Enviroment Simulator test Save file" << std::endl;
    testMap.saveMap("testFileMap.map");

    //Map from file
    testResultsFile << "Enviroment Simulator test Map from file" << std::endl;

    Map testFileMap("testFileMap.map");

    try{
        Map testFileMap("testFileMap.map");
    }
    catch(int e){
        if(e != 2){
            testResultsFile << "Error: ";
            testResultsFile << "Map from corrupt file: " << "Excpention error." << std::endl;
            ++error;
        }
    }

    if(testFileMap.width != size || testFileMap.height != size){
        testResultsFile << "Error: ";
        testResultsFile << "Map from file: " << "Map y size incorret" << std::endl;
        ++error;
    }

    if(testFileMap.width != size || testFileMap.height != size){
        testResultsFile << "Error: ";
        testResultsFile << "Map from file: " << "Map x size incorret" << std::endl;
        ++error;
    }

    for(int y = 0; y < testFileMap.height; y++){
        for(int x = 0; x < testFileMap.width; x++){
            if(testFileMap.getMapObject(y,x) != 0){
                testResultsFile << "Error: ";
                testResultsFile << "Map from file: " << "Conntent error. != 0" << std::endl;
                ++error;
            }
        }
    }

    for(int y = 0; y < testFileMap.height; y++){
        for(int x = 0; x < testFileMap.width; x++){
            testFileMap.setMapObject(1,y,x);
        }
    }

    for(int y = 0; y < testFileMap.height; y++){
        for(int x = 0; x < testFileMap.width; x++){
            if(testFileMap.getMapObject(y,x) != 1){
                testResultsFile << "Error: ";
                testResultsFile << "Map from file: " << "Conntent error. != 1" << std::endl;
                ++error;
            }
        }
    }

    //Map from corrupt file
    testResultsFile << "Enviroment Simulator test Map from corrupt file" << std::endl;
    try{
        Map corruptMap("testFileMapCorrupt.map");
        ++error;
    }
    catch(int e){
        if(e != 2){
            testResultsFile << "Error: ";
            testResultsFile << "Map from corrupt file: " << "Excpention error." << std::endl;
        }
    }

    for(int y = 0; y < testMap.height; y++){
        for(int x = 0; x < testMap.width; x++){
            testMap.setMapObject(0,y,x);
        }
    }


    //Simuate test
    testResultsFile << "Enviroment Simulator test Simulate" << std::endl;

    Map *tp = new Map("testSimulateMap.map" , size, size);
    tp->setMapObject(1,1,9);
    tp->setMapObject(1,15,15);

    SimulateMap testSim(tp);

    testSim.addCheckPoint(6,2);

    testSim.addCheckPoint(21,21);
    testResultsFile << "addCheckPoint 21 21" << std::endl;

    testSim.addCheckPoint(-1,-1);
    testResultsFile << "addCheckPoint -1 -1" << std::endl;

    testSim.simulate();
    testResultsFile << "Simulate: " << "Lest see" << std::endl;

    Map *pt = new Map("temp.map", size, size);

    SimulateMap testSimEmpty(pt);

    testSimEmpty.simulate();
    testResultsFile << "Simulate: " << "Lest see" << std::endl;

    testSimEmpty.getPointCloud();
    testResultsFile << "Simulate: " << "Lest see" << std::endl;

    //Objects behind objects test

    Map *tM = new Map("testMap.map", size,size);
    //right side
    tM->setMapObject(1,5,8);
    testResultsFile << "addObject 5 8 right side from checkpoint" << std::endl;
    tM->setMapObject(1,5,9);
    testResultsFile << "addObject 5 9 right side from checkpoint" << std::endl;
    //left side
    tM->setMapObject(1,5,6);
    testResultsFile << "addObject 5 6 left side from checkpoint" << std::endl;
    tM->setMapObject(1,5,5);
    testResultsFile << "addObject 5 5 left side from checkpoint" << std::endl;
    //upper side
    tM->setMapObject(1,4,7);
    testResultsFile << "addObject 4 7 upper side from checkpoint" << std::endl;
    tM->setMapObject(1,3,7);
    testResultsFile << "addObject 3 7 upper side from checkpoint" << std::endl;
    //lower side
    tM->setMapObject(1,6,7);
    testResultsFile << "addObject 7 6 lower side from checkpoint" << std::endl;
    tM->setMapObject(1,7,7);
    testResultsFile << "addObject 7 7 lower side from checkpoint" << std::endl;

    //left up side diagonal
    tM->setMapObject(1,4,6);
    testResultsFile << "addObject 4 6 left up side diagonal checkpoint" << std::endl;
    tM->setMapObject(1,3,5);
    testResultsFile << "addObject 5 3 left up side diagonal checkpoint" << std::endl;

    //left down side diagonal
    tM->setMapObject(1,6,6);
    testResultsFile << "addObject 6 6 left down side diagonal checkpoint" << std::endl;
    tM->setMapObject(1,7,5);
    testResultsFile << "addObject 5 7 left down side diagonal checkpoint" << std::endl;

    //right up side diagonal
    tM->setMapObject(1,4,8);
    testResultsFile << "addObject 8 4 right up side diagonal checkpoint" << std::endl;
    tM->setMapObject(1,3,9);
    testResultsFile << "addObject 9 3 right up side diagonal checkpoint" << std::endl;

    //right down side diagonal
    tM->setMapObject(1,6,8);
    testResultsFile << "addObject 8 6 right down side diagonal checkpoint" << std::endl;
    tM->setMapObject(1,7,9);
    testResultsFile << "addObject 9 7 right down side diagonal checkpoint" << std::endl;

    SimulateMap tS(tM);

    tS.addCheckPoint(7,5);
    testResultsFile << "addCheckPoint 5 7" << std::endl;

    tS.simulate();
    testResultsFile << "Enviroment Simulator object behind object test PointCloud" << std::endl;
    Pointcloud pointc = tS.getPointCloud();

    for(Pointcloud::Point p : *pointc.getPoints()){
        if(p.X == 2 && p.Y == 0){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Right side object behind object scanned. FAILURE!" << std::endl;
            ++error;
        }
        else if(p.X == -2 && p.Y == 0){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Left side object behind object scanned. FAILURE!" << std::endl;
            ++error;
        }
        else if(p.X == 0 && p.Y == 2){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Upper side object behind object scanned. FAILURE!" << std::endl;
            ++error;
        }
        else if(p.X == 0 && p.Y == -2){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Lower side object behind object scanned. FAILURE!" << std::endl;
            ++error;
        }
        else if(p.X ==  -2 && p.Y == -2){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Upper left diagonal side object behind object scanned. FAILURE!" << std::endl;
            ++error;
        }
        else if(p.X == 2 && p.Y == -2){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Lower left diagonal side object behind object scanned. FAILURE!" << std::endl;
            ++error;
        }
        else if(p.X == 2 && p.Y == 2){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Lower right diagonal side object behind object scanned. FAILURE!" << std::endl;
            ++error;
        }
        else if(p.X == -2 && p.Y == 2){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Upper right diagonal side object behind object scanned. FAILURE!" << std::endl;
            ++error;
        }
    }

    //PointCloud test
    testResultsFile << "Enviroment Simulator test PointCloud" << std::endl;
    Pointcloud pC = testSim.getPointCloud();
    if(pC.getPoints()->size() > 1){
        testResultsFile << "Error: ";
        ++error;
        testResultsFile << "PointCloud: " << "Radius failed" << std::endl;
    }
    for(Pointcloud::Point p : *pC.getPoints()){
        //std::cout << "x: " << p.X << " y: " << p.Y;
        if(p.X != 3){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "X wrong" << std::endl;
            ++error;
        }
        if(p.Y != -1){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Y wrong" << std::endl;
            ++error;
        }
    }

    //save pc
    pC.savePointsToFile("testpC.pcl");
    Pointcloud loadpC;
    //load pc from file
    loadpC.loadPointsFromFile("testpC.pcl");
    //make map from loaded pc
    try{
        Map pCloadMap("testpC.map", &loadpC);
        //check point
        if(pCloadMap.getMapObject(0,3) != 1){
            testResultsFile << "PointCloud: " << "Load from file failed" << std::endl;
        }
    }
    catch(int e){
        if(e != 2){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Excpention error." << std::endl;
            ++error;
        }
    }

    //Done
    testResultsFile << "Enviroment Simulator test done" << std::endl;
    if(error == 0){
        testResultsFile << "Test Succes!" << std::endl;
        std::cout << "Test Succes!" << std::endl;
    }

    testResultsFile << '\n' << '\n';
    testResultsFile.close();
    std::cout << "Enviroment Simulator test done" << std::endl;
    return error;
}
예제 #11
0
파일: apitest.c 프로젝트: zandrey/ti-ludev
int main(int argc, char *argv[])
{
    size_t size;
    int version;
    CMEM_BlockAttrs attrs;
    int i;
    int c;
    
    non_interactive_flag = FALSE;

    while ((c = getopt(argc, argv, "n")) != -1) {
	switch (c) {
	case 'n':
	    non_interactive_flag = TRUE; 	
	    break;

	default:
	    fprintf(stderr, "Usage: %s [-n] <Number of bytes to allocate>\n",
		    argv[0]);
	    fprintf(stderr,
                    "    -n: non-interactive mode (no ENTER prompts)\n");
	    exit(EXIT_FAILURE);
	}
    }

    if ((argc - optind + 1) != 2) {
	fprintf(stderr, "Usage: %s [-n] <Number of bytes to allocate>\n",
	        argv[0]);
	fprintf(stderr, "    -n: non-interactive mode (no ENTER prompts)\n");
	exit(EXIT_FAILURE);
    }

    errno = 0;
    size = strtol(argv[optind], NULL, 0);

    if (errno) {
	fprintf(stderr, "Bad argument ('%s'), strtol() set errno %d\n",
	        argv[optind], errno);
        exit(EXIT_FAILURE);
    }

    /* First initialize the CMEM module */
    if (CMEM_init() == -1) {
        fprintf(stderr, "Failed to initialize CMEM\n");
        exit(EXIT_FAILURE);
    }

    printf("CMEM initialized.\n");

    version = CMEM_getVersion();
    if (version == -1) {
	fprintf(stderr, "Failed to retrieve CMEM version\n");
        exit(EXIT_FAILURE);
    }
    printf("CMEM version = 0x%x\n", version);

    testMap(size);
    testAllocPhys(size);

    testCMA(size);

    if (CMEM_getNumBlocks(&nblocks)) {
	fprintf(stderr, "Failed to retrieve number of blocks\n");
        exit(EXIT_FAILURE);
    }
    printf("\n# of CMEM blocks (doesn't include possible CMA global 'block'): %d\n", nblocks);

    if (nblocks) {
	for (i = 0; i < nblocks; i++) {
	    if (CMEM_getBlockAttrs(i, &attrs) == -1) {
		fprintf(stderr, "Failed to retrieve CMEM memory block %d bounds\n", i);
	    }
	    else {
		printf("CMEM memory block %d: phys start = %#llx, size = %#llx\n",
		       i, (unsigned long long)attrs.phys_base, attrs.size);
	    }

	    testHeap(size, i);
	    testHeap(size, i);
	    testPools(size, i);
	    testPools(size, i);
	    testCache(size, i);
	}
    }
    else {
	printf("    no physical block found, not performing block-based testing\n");
    }

    /* block 'nblocks' is the special CMEM CMA "block" */
    testPools(size, CMEM_CMABLOCKID);

    printf("\nexiting...\n");
    if (CMEM_exit() < 0) {
        fprintf(stderr, "Failed to finalize the CMEM module\n");
    }
    printf("...test done\n");

    exit(EXIT_SUCCESS);
}