Esempio n. 1
0
static void test_dbd_generic(abts_case *tc, apr_dbd_t* handle, 
                             const apr_dbd_driver_t* driver)
{
    void* native;
    apr_pool_t *pool = p;
    apr_status_t rv;

    native = apr_dbd_native_handle(driver, handle);
    ABTS_PTR_NOTNULL(tc, native);

    rv = apr_dbd_check_conn(driver, pool, handle);

    create_table(tc, handle, driver);
    select_rows(tc, handle, driver, 0);
    insert_data(tc, handle, driver, 5);
    select_rows(tc, handle, driver, 5);
    delete_rows(tc, handle, driver);
    select_rows(tc, handle, driver, 0);
    drop_table(tc, handle, driver);

    test_escape(tc, handle, driver);

    rv = apr_dbd_close(driver, handle);
    ABTS_ASSERT(tc, "failed to close database", rv == APR_SUCCESS);
}
Esempio n. 2
0
//hlavni funkce starajici se o chod aplikace
int main(int argc, char **argv )
{
	unsigned int cnt = 0,old_score=1;
	char_cnt = 0;
	last_ch = 0;
	//iniciaizace HW
	initialize_hardware();
	keyboard_init();
	
	int random_number,i,j;
	Tshape myshape;
	Tmatrix matrix,pane,pom;
	int pom_matrix[8][8] = {0};
	char c=0;
	int latest_line;

	//srand(2);
	//vytvoreni noveho utvaru
	myshape = create_shape(rand()%8);
	//posun na zacatek
	matrix = move_it(myshape,pom_matrix);
	//ulozeni noveho utvaru
	pane = save_it(matrix,pom_matrix);


	set_led_d6(1);                       // rozsviceni D6
	set_led_d5(1);                       // rozsviceni D5

	//inicializace LED displeje
	P6DIR=0xff;
	P4DIR=0x0f;
	P2DIR=0xf0;
	P4OUT=0x00;
	P2OUT=0x00;
	P6OUT=0xff;
	while (1)
	{
		delay_ms(1);
		cnt++;
		//pri zmacknuti klavesy
		if (c!=last_ch){
			c=last_ch;
			//pokud byla zmacknuta 6
			if (c=='6'){
				//posunu se
				x++;
				//pokusim se ulozit na to misto utvar
				matrix = move_it(myshape,pom_matrix);
				//pokud nelze ulozit	
				if (matrix.count!=4){
					//vratim se
					x--;
					//a ulozim
					matrix = move_it(myshape,pom_matrix);				
				}
			}
			//pri zmacknuti 4  
			else if (c=='4'){
				//posunu se
				x--;
				//pokusim se ulozit
				matrix = move_it(myshape,pom_matrix);
				//pokud bych vypsal mene jak 4 znaky z utvaru
				if (matrix.count!=4){
					//posouvam se zpatky
					x++;
					matrix = move_it(myshape,pom_matrix);
				}
			}
			//pokud nactu 8
			else if (c=='8'){
				//posunu se
				y++;
				//pokusim se ulozit
				matrix = move_it(myshape,pom_matrix);
				if (matrix.count!=4){
					//pokud nelze posun, posunu se nazpet
					y--;
					matrix = move_it(myshape,pom_matrix);
					matrix.last_line = 1;
				}			
			}
			//rotace
			else if (c=='5'){
				//pouzivam prvne rotate_back kvuli "hezci" rotaci
				myshape = rotate_back(myshape);
				//pokusim se ulozit dany utvar
				matrix = move_it(myshape,pom_matrix);
				//pokud pri posunu nelze vypsat vsechny 4 prvky daneho utvaru
				if (matrix.count!=4){
					//posunu se zpatky
					myshape = rotate(myshape);
					matrix = move_it(myshape,pom_matrix);
				}		
			}
			else
			{
				continue;
			}
			//ulozim do vysledneho hraciho pole
			pane = save_it(matrix,pom_matrix);
			//pokud jsem nacetl posledni radek
			if (matrix.last_line==1)
			{
				//ulozim si hraci pole do pomocne matice
				for (i=0;i<8;i++)
				{
					for (j=0;j<8;j++)
					{
						pom_matrix[i][j] = pane.shape[i][j];
					}
				}
				matrix.last_line=0;
				//smazu radky
				pane=delete_rows(pane);

				x=0;
				y=0;
				//vygeneruji novy utvar
				myshape = create_shape(rand()%8);
				int i,t;
				//ulozim do pomocne matice hraci pole
				for (i=0;i<8;i++)
					for (t=0;t<8;t++)
						pom_matrix[i][t]=pane.shape[i][t];
				//posunu nove vygenerovany utvar na zacatek hraciho pole
				matrix = move_it(myshape,pom_matrix);
				//ulozim tento stav
				pane = save_it(matrix,pom_matrix);
				
			}
			c=last_ch;
		}
		//tisknuti skore
		if (old_score!=score && (cnt%100)==0){
			old_score=score;
			print_score("Score: ");
		}
		
		if (cnt > 1000)
		{
			cnt = 0;
			flip_led_d6();                   // negace portu na ktere je LED
		}
		
		print_it(pane.shape);
		keyboard_idle();                   // obsluha klavesnice
		terminal_idle();                   // obsluha terminalu
  } 
	
	return 0;
}
Esempio n. 3
0
int main(int argc, const char** argv) {
    ndb_init();

    int operationType = 0;
    int tupTest = 0;
    int scanTest = 0;

    Ndb* pNdb = new Ndb("TEST_DB");
    pNdb->init();

    if (argc != 4  ||  sscanf(argv[1],"%d", &operationType) != 1) {
        operationType = 1 ;
    }
    if (argc != 4  ||  sscanf(argv[2],"%d", &tupTest) != 1) {
        tupTest = 1 ;
    }
    if (argc != 4  ||  sscanf(argv[3],"%d", &scanTest) != 1) {
        scanTest = 1 ;
    }

    ndbout << endl
           << "Test the interpreter in TUP using SimpleTable with\n"
           << nRecords << " records" << endl << endl ;

    if (pNdb->waitUntilReady(30) != 0) {
        ndbout << "NDB is not ready" << endl;
        return -1;
    }

    // Init the pk and attr values.
    for (int i = 0; i < NUMBEROFRECORDS; i ++)
        pkValue[i] = attrValue[i] = i ;

    setAttrNames() ;
    setTableNames() ;

    const void * p = NDBT_Table::discoverTableFromDb(pNdb, tableName);
    if (p != 0) {
        create_table(pNdb);
    }

    write_rows(pNdb);

    ndbout << endl << "Starting interpreter in TUP test." << endl << "Operation type: " ;

    switch(operationType) {
    case 1:
        ndbout << "openScanRead" << endl;
        scan_rows(pNdb,  operationType,  tupTest,  scanTest);
        break;
    case 2:
        ndbout << "openScanExclusive" << endl;
        scan_rows(pNdb,  operationType,  tupTest,  scanTest);
        break;
    case 3:
        ndbout << "interpretedUpdateTuple" << endl;
        update_rows(pNdb,  tupTest,  operationType);
        break;
    case 4:
        ndbout << "interpretedDirtyUpdate" << endl;
        update_rows(pNdb,  tupTest,  operationType);
        break;
    case 5:
        ndbout << "interpretedDeleteTuple" << endl;
        delete_rows(pNdb,  tupTest,  operationType);
        break;
    case 6:
        ndbout << "deleteTuple" << endl;
        break;
    case 7:
        ndbout << "insertTuple" << endl;
        break;
    case 8:
        ndbout << "updateTuple" << endl;
        break;
    case 9:
        ndbout << "writeTuple" << endl;
        break;
    case 10:
        ndbout << "readTuple" << endl;
        break;
    case 11:
        ndbout << "readTupleExclusive" << endl;
        break;
    case 12:
        ndbout << "simpleRead" << endl;
        break;
    case 13:
        ndbout << "dirtyRead" << endl;
        break;
    case 14:
        ndbout << "dirtyUpdate" << endl;
        break;
    case 15:
        ndbout << "dirtyWrite" << endl;
        break;
    default:
        break ;

    }

//  read_and_verify_rows(pNdb, false);

//  delete_rows(pNdb, 0, 0) ;
    delete pNdb ;

    if (bTestPassed == 0) {
        ndbout << "OK: test passed" << endl;
        exit(0);
    } else {
        ndbout << "FAIL: test failed" << endl;
        exit(-1);
    }
}