IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 14, 2005, 5:20:36 PM (21 years ago)
Author:
evanalst
Message:

Update test case for psCreateTable to verify invalid arguments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/dataIO/tst_psDB.c

    r4263 r4270  
    99 *  @author Aaron Culliney, MHPCC
    1010 *
    11  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-06-15 01:48:25 $
     11 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-06-15 03:20:36 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    7272                              {TPDBInit,           841,  "dbInit",            0, false},
    7373                              {TPDBChange,         842,  "dbChange",          0, false},
    74                               {TPDBCreateTable,     -3,  "dbCreateTable",     0, false},
     74                              {TPDBCreateTable,    843,  "dbCreateTable",     0, false},
    7575                              {TPDBDropTable,       -4,  "dbDropTable",       0, false},
    7676                              {TPDBSelectColumn,    -5,  "dbSelectColumn",    0, false},
     
    305305
    306306    // Attempt to initialize database with invalid arguments
     307    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for invalid host");
    307308    dbh = psDBInit("xxx",NULL,NULL,NULL);
    308309    if(dbh != NULL) {
     
    312313
    313314    // Attempt cleanup database/connection with NULL psDB object
     315    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL database objec");
    314316    psDBCleanup(NULL);
    315317
     
    336338
    337339    // Attemp to change database to invalid database name
     340    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for invalid database");
    338341    if(psDBChange(dbh,"abc")) {
    339342        psError(PS_ERR_UNKNOWN,true,"Did not expect return true for unknown database name");
     
    345348
    346349    // Attempt to change database with NULL database object
     350    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for null database object");
    347351    if(psDBChange(NULL,dbname)) {
    348352        psError(PS_ERR_UNKNOWN,true,"Did not expect return true for NULL database object");
     
    353357}
    354358
    355 // Testpoint #XXX, psDBCreateTable shall create tables in the test database ...
     359// Testpoint #843, psDBCreateTable shall create tables in the test database ...
    356360psS32 TPDBCreateTable( void )
    357361{
    358     psS32 failed = 0;
    359362    psDB *dbh = NULL;
    360363    const char* table = "table1";
     364
     365    // Create metadata for table definition
    361366    psMetadata *md = _get_CreateTableMetadata();
    362367
    363     dbh = _init_psDB();
    364     if (dbh == NULL) {
    365         return 1;
    366     }
    367 
    368     psLogMsg( __func__, PS_LOG_INFO, "psDBCreateTable shall create a new table in the new test database.\n" );
    369 
    370     failed = ! psDBCreateTable(dbh, table, md);
    371     if (!failed) {
     368    // Initialize database connection
     369    dbh = _init_psDB();
     370    if (dbh == NULL) {
     371        psError(PS_ERR_UNKNOWN,true,"Did not expect NULL for valid argument in database connection");
     372        return 1;
     373    }
     374
     375    // Attempt to create database table with valid arguments
     376    if(!psDBCreateTable(dbh, table, md)) {
     377        psError(PS_ERR_UNKNOWN,true,"Did not expect return of false for valid arguments");
     378        return 2;
     379    } else {
     380        // Drop the table from the test database
    372381        psDBDropTable(dbh, table);
    373382    }
    374383
     384    // Free metadata definition of table
    375385    psFree(md);
    376     psDBCleanup(dbh);
    377 
    378     return failed;
     386
     387    // Attempt to create table with NULL table definition
     388    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for NULL parameter");
     389    if(psDBCreateTable(dbh,table,NULL)) {
     390        psError(PS_ERR_UNKNOWN,true,"Did not expect return of true for NULL metadata object");
     391        return 3;
     392    }
     393
     394    // Attempt to create table with NULL connection
     395    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for NULL parameter");
     396    if(psDBCreateTable(NULL, table, md)) {
     397        psError(PS_ERR_UNKNOWN,true,"Did not expect return of true for NULL database object");
     398        return 4;
     399    }
     400
     401    // Close/cleanup database connection
     402    psDBCleanup(dbh);
     403
     404    return 0;
    379405}
    380406
Note: See TracChangeset for help on using the changeset viewer.