From: pharvey Date: December 27 2005 3:12am Subject: Connector/ODBC 5 commit: r17 - in MYODBCIns: MYODBCInsLib MYODBCInsTest include List-Archive: http://lists.mysql.com/commits/422 Message-Id: <200512270312.jBR3CVJY024321@bk-internal.mysql.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added: MYODBCIns/MYODBCInsTest/MYODBCInsTest.cpp Removed: MYODBCIns/MYODBCInsTest/MYODBCInsTest.c Modified: MYODBCIns/MYODBCInsLib/MYODBCInsDataSource.cpp MYODBCIns/MYODBCInsLib/MYODBCInsDriver.cpp MYODBCIns/MYODBCInsTest/MYODBCInsTest.pro MYODBCIns/MYODBCInsTest/MYODBCInsTest.vpj MYODBCIns/include/MYODBCInsDataSource.h MYODBCIns/include/MYODBCInsDriver.h Log: UNICODE: code from Linux/64 - time to do some, brief, testing on XP/32 Modified: MYODBCIns/MYODBCInsLib/MYODBCInsDataSource.cpp =================================================================== --- MYODBCIns/MYODBCInsLib/MYODBCInsDataSource.cpp 2005-12-26 20:17:46 UTC (rev 16) +++ MYODBCIns/MYODBCInsLib/MYODBCInsDataSource.cpp 2005-12-27 03:12:31 UTC (rev 17) @@ -605,6 +605,11 @@ stringUSER = QString::null; } +bool MYODBCInsDataSource::doDelete( const QString &stringDataSourceName ) +{ + return SQLRemoveDSNFromIni( stringDataSourceName.toLocal8Bit() ); +} + MYODBCInsDataSource MYODBCInsDataSource::operator=( MYODBCInsDataSource rval ) { stringDATABASE = rval.stringDATABASE; @@ -624,20 +629,20 @@ return *this; } -QTextStream &operator<<( QTextStream &stream, MYODBCInsDataSource rval ) +QTextStream &operator<<( QTextStream &stream, const MYODBCInsDataSource &rval ) { - stream << "DATABASE : " << rval.getDATABASE() << endl; - stream << "DESCRIPTION : " << rval.getDESCRIPTION() << endl; - stream << "DRIVER : " << rval.getDRIVER() << endl; - stream << "DriverFileName: " << rval.getDriverFileName() << endl; - stream << "DSN : " << rval.getDSN() << endl; - stream << "OPTION : " << rval.getOPTION() << endl; - stream << "PASSWORD : " << rval.getPASSWORD() << endl; - stream << "PORT : " << rval.getPORT() << endl; - stream << "SERVER : " << rval.getSERVER() << endl; - stream << "SOCKET : " << rval.getSOCKET() << endl; - stream << "STMT : " << rval.getSTMT() << endl; - stream << "USER : " << rval.getUSER() << endl; + stream << "DATABASE : " << rval.stringDATABASE << endl; + stream << "DESCRIPTION : " << rval.stringDESCRIPTION << endl; + stream << "DRIVER : " << rval.stringDRIVER << endl; + stream << "DriverFileName: " << rval.stringDriverFileName << endl; + stream << "DSN : " << rval.stringDSN << endl; + stream << "OPTION : " << rval.stringOPTION << endl; + stream << "PASSWORD : " << rval.stringPASSWORD << endl; + stream << "PORT : " << rval.stringPORT << endl; + stream << "SERVER : " << rval.stringSERVER << endl; + stream << "SOCKET : " << rval.stringSOCKET << endl; + stream << "STMT : " << rval.stringSTMT << endl; + stream << "USER : " << rval.stringUSER << endl; return stream; } Modified: MYODBCIns/MYODBCInsLib/MYODBCInsDriver.cpp =================================================================== --- MYODBCIns/MYODBCInsLib/MYODBCInsDriver.cpp 2005-12-26 20:17:46 UTC (rev 16) +++ MYODBCIns/MYODBCInsLib/MYODBCInsDriver.cpp 2005-12-27 03:12:31 UTC (rev 17) @@ -187,6 +187,11 @@ stringSETUP = QString::null; } +bool MYODBCInsDriver::doDelete( const QString &stringDriverName, bool bRemoveDataSourceNames, LPDWORD pnUsageCount ) +{ + return SQLRemoveDriver( stringDriverName.toLocal8Bit(), bRemoveDataSourceNames, pnUsageCount ); +} + MYODBCInsDriver MYODBCInsDriver::operator=( MYODBCInsDriver rval ) { stringFriendlyName = rval.stringFriendlyName; @@ -204,13 +209,12 @@ \param pDriver A pointer to a valid MYODBC_INS_DRIVER (may be null). */ -QTextStream &operator<<( QTextStream &stream, MYODBCInsDriver rval ) +QTextStream &operator<<( QTextStream &stream, const MYODBCInsDriver &rval ) { - stream << "FriendlyName: " << rval.getFriendlyName() << endl; - stream << "DRIVER : " << rval.getDRIVER() << endl; - stream << "SETUP : " << rval.getSETUP() << endl; + stream << "FriendlyName: " << rval.stringFriendlyName << endl; + stream << "DRIVER : " << rval.stringDRIVER << endl; + stream << "SETUP : " << rval.stringSETUP << endl; return stream; } - Deleted: MYODBCIns/MYODBCInsTest/MYODBCInsTest.c =================================================================== --- MYODBCIns/MYODBCInsTest/MYODBCInsTest.c 2005-12-26 20:17:46 UTC (rev 16) +++ MYODBCIns/MYODBCInsTest/MYODBCInsTest.c 2005-12-27 03:12:31 UTC (rev 17) @@ -1,43 +0,0 @@ -#include -#include -#include - -#include - -typedef struct tTEST -{ - char * name; - int (*pfunc)(); -} TEST; - -int test1() -{ - - return 1; -} - -int main() -{ - TEST tests[2]= - { - {"test1", test1}, - {NULL, NULL} - }; - int n; - - for ( n = 0; tests[n].name; n++ ) - { - printf( "%-40s", tests[n].name ); - if ( tests[n].pfunc() ) - printf( "[ OK ]\n" ); - else - { - printf( "[FAILED]\n" ); - exit( 1 ); - } - } - - return 0; -} - - Copied: MYODBCIns/MYODBCInsTest/MYODBCInsTest.cpp (from rev 13, MYODBCIns/MYODBCInsTest/MYODBCInsTest.c) =================================================================== --- MYODBCIns/MYODBCInsTest/MYODBCInsTest.c 2005-12-24 06:04:53 UTC (rev 13) +++ MYODBCIns/MYODBCInsTest/MYODBCInsTest.cpp 2005-12-27 03:12:31 UTC (rev 17) @@ -0,0 +1,174 @@ +#include + +typedef struct tTEST +{ + char * name; + int (*pfunc)(); +} TEST; + +QString stringOutput; + +/* create new DRIVER */ +int test1() +{ + MYODBCInsDriver driver; + + driver.setFriendlyName( "mytestDRIVER" ); + driver.setDRIVER( "mytestDriver.so" ); + driver.setSETUP( "mytestSetup.so" ); + + if ( !driver.doWrite() ) + return 0; + + QTextStream textstream( &stringOutput ); + textstream << driver; + + return 1; +} + +/* verify new DRIVER */ +int test2() +{ + MYODBCInsDriver driver; + + if ( !driver.doRead( "mytest Friendly Name" ) ) + return 0; + + QString stringResult; + QTextStream textstream( &stringResult ); + textstream << driver; + + if ( stringResult != stringOutput ) + return 0; + + return 1; +} + +/* create new DSN */ +int test3() +{ + QStringList stringlistDataSourceNames = MYODBCInsDataSource::getDataSourceNames( MYODBC_INS_DATASOURCE_SCOPE_USER ); + + if ( stringlistDataSourceNames.contains( "mytestDSN" ) ) + return 0; + + MYODBCInsDataSource datasource( MYODBC_INS_DATASOURCE_MODE_DSN_ADD ); + + datasource.setScope( MYODBC_INS_DATASOURCE_SCOPE_USER ); + datasource.setDATABASE( "mytestDATABASE" ); + datasource.setDESCRIPTION( "mytestDESCRIPTION" ); + datasource.setDRIVER( "mytestDRIVER" ); + datasource.setDriverFileName( "mytestDriver.so" ); + datasource.setDSN( "mytestDSN" ); + datasource.setOPTION( "3" ); + datasource.setPASSWORD( "mytestPASSWORD" ); + datasource.setPORT( "99" ); + datasource.setSERVER( "mytestSERVER" ); + datasource.setSOCKET( "100" ); + datasource.setSTMT( "" ); + + if ( !datasource.doWrite() ) + return 0; + + QTextStream textstream( &stringOutput ); + textstream << datasource; + + return 1; +} + +/* verify new DSN */ +int test4() +{ + MYODBCInsDataSource datasource( MYODBC_INS_DATASOURCE_MODE_DSN_EDIT ); + + datasource.setScope( MYODBC_INS_DATASOURCE_SCOPE_USER ); + if ( !datasource.doRead( "mytestDSN" ) ) + return 0; + + QString stringResult; + QTextStream textstream( &stringResult ); + textstream << datasource; + + if ( stringResult != stringOutput ) + return 0; + + return 1; +} + +/* delete DSN */ +int test5() +{ + if ( !MYODBCInsDataSource::doDelete( "mytestDSN" ) ) + return 0; + + return 1; +} + +/* verify delete DSN */ +int test6() +{ + QStringList stringlistDataSourceNames = MYODBCInsDataSource::getDataSourceNames( MYODBC_INS_DATASOURCE_SCOPE_USER ); + + if ( stringlistDataSourceNames.contains( "mytestDSN" ) ) + return 0; + + return 1; +} + +/* delete DRIVER */ +int test7() +{ + DWORD nUsage = 0; + + if ( !MYODBCInsDriver::doDelete( "mytestDRIVER", true, &nUsage ) ) + return 0; + + if ( nUsage != 0 ) + return 0; + + return 1; +} + +/* verify delete DRIVER */ +int test8() +{ + QStringList stringlistDriverNames = MYODBCInsDriver::getDriverNames(); + + if ( stringlistDriverNames.contains( "mytestDRIVER" ) ) + return 0; + + return 1; +} + +int main() +{ + TEST tests[9]= + { + {"test1", test1}, + {"test2", test2}, + {"test3", test3}, + {"test4", test4}, + {"test5", test5}, + {"test6", test6}, + {"test7", test7}, + {"test8", test8}, + {NULL, NULL} + }; + int n; + + for ( n = 0; tests[n].name; n++ ) + { + printf( "%-40s", tests[n].name ); + if ( tests[n].pfunc() ) + printf( "[ OK ]\n" ); + else + { + printf( "[FAILED]\n" ); + exit( 1 ); + } + } + + return 0; +} + + Modified: MYODBCIns/MYODBCInsTest/MYODBCInsTest.pro =================================================================== --- MYODBCIns/MYODBCInsTest/MYODBCInsTest.pro 2005-12-26 20:17:46 UTC (rev 16) +++ MYODBCIns/MYODBCInsTest/MYODBCInsTest.pro 2005-12-27 03:12:31 UTC (rev 17) @@ -6,11 +6,13 @@ DESTDIR = ../../bin include( ../../common.pri ) include( ../../config.pri ) +include( ../../defines.pri ) +include( ../../odbc.pri ) CONFIG += console INCLUDEPATH += ../../MYODBCC/include INCLUDEPATH += ../include LIBS += -L../../lib -LIBS += -lMYODBCIns -lMYODBCC +LIBS += -lMYODBCIns # ######################################################### # FILES @@ -18,5 +20,5 @@ HEADERS = SOURCES = \ - MYODBCInsTest.c + MYODBCInsTest.cpp Modified: MYODBCIns/MYODBCInsTest/MYODBCInsTest.vpj =================================================================== --- MYODBCIns/MYODBCInsTest/MYODBCInsTest.vpj 2005-12-26 20:17:46 UTC (rev 16) +++ MYODBCIns/MYODBCInsTest/MYODBCInsTest.vpj 2005-12-27 03:12:31 UTC (rev 17) @@ -184,7 +184,7 @@ - + + #include #include #include @@ -22,9 +23,10 @@ bool doRead( const QString &stringFriendlyName ); bool doWrite(); void doClear(); + static bool doDelete( const QString &stringDriverName, bool bRemoveDataSourceNames, LPDWORD pnUsageCount ); MYODBCInsDriver operator=( MYODBCInsDriver rval ); - QTextStream &operator<<( MYODBCInsDriver rval ); + friend QTextStream &operator<<( QTextStream &stream, const MYODBCInsDriver &rval ); protected: /*! @@ -37,5 +39,6 @@ QString stringSETUP; /* File name - typically complete abs path. (ie "/usr/lib/libmyodbc3S.so") */ }; + #endif