IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 15, 2005, 9:53:05 AM (21 years ago)
Author:
evanalst
Message:

Update test case for function psDBDropTable to verify invalid arguments.

File:
1 edited

Legend:

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

    r4270 r4272  
    99 *  @author Aaron Culliney, MHPCC
    1010 *
    11  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-06-15 03:20:36 $
     11 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-06-15 19:53:05 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    7373                              {TPDBChange,         842,  "dbChange",          0, false},
    7474                              {TPDBCreateTable,    843,  "dbCreateTable",     0, false},
    75                               {TPDBDropTable,       -4,  "dbDropTable",       0, false},
     75                              {TPDBDropTable,      844,  "dbDropTable",       0, false},
    7676                              {TPDBSelectColumn,    -5,  "dbSelectColumn",    0, false},
    7777                              {TPDBSelectColumnNum, -6,  "dbSelectColumnNum", 0, false},
     
    405405}
    406406
    407 // Testpoint #XXX, psDBDropTable shall create tables in the test database ...
     407// Testpoint #844, psDBDropTable shall remove tables in the test database ...
    408408psS32 TPDBDropTable( void )
    409409{
     
    411411    psDB *dbh = NULL;
    412412    const char* table = "table2";
     413
     414    // Create table definition metadata
    413415    psMetadata *row=NULL, *md = _get_CreateTableMetadata();
    414416
    415     dbh = _init_psDB();
    416     if (dbh == NULL) {
    417         return 1;
    418     }
    419 
    420     psLogMsg( __func__, PS_LOG_INFO, "psDBDropTable shall create/drop a new table in the new test database.\n" );
    421 
     417    // Initialize database connection
     418    dbh = _init_psDB();
     419    if (dbh == NULL) {
     420        psError(PS_ERR_UNKNOWN,true,"Did not expect NULL return to initialize database");
     421        return 1;
     422    }
     423
     424    // Create table in database
    422425    failed = ! psDBCreateTable(dbh, table, md);
    423426    if (!failed) {
     427
     428        // Drop table with valid arguments
    424429        failed = ! psDBDropTable(dbh, table);
    425430
    426         // insert should fail ...
     431        // insert should fail since the table has been drop from database
    427432        psLogMsg( __func__, PS_LOG_INFO, "psDBDropTable: insert should fail here...\n" );
    428433        row = _get_row();
     
    432437        }
    433438        psFree(row);
     439    }
     440
     441    // Attempt to drop table from NULL psDB object
     442    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for NULL database object");
     443    if(psDBDropTable(NULL,table)) {
     444        psError(PS_ERR_UNKNOWN,true,"Did not return false as expected for NULL database object");
     445        return 2;
     446    }
     447
     448    // Attempt to drop table from valid psDB but invalid table
     449    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid table");
     450    if(psDBDropTable(dbh,"table99")) {
     451        psError(PS_ERR_UNKNOWN,true,"Did not return false as expected for invalid table");
     452        return 3;
     453    }
     454
     455    // Attempt to drop table from valid psDB but NULL table
     456    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for NULL table");
     457    if(psDBDropTable(dbh,NULL)) {
     458        psError(PS_ERR_UNKNOWN,true,"Did not return false as expected for NULL table");
     459        return 4;
    434460    }
    435461
Note: See TracChangeset for help on using the changeset viewer.