Modified:
MYODBCDes/MYODBCDesLib/MYODBCDes.cpp
MYODBCDes/MYODBCDesLib/MYODBCDesAPD.cpp
MYODBCDes/MYODBCDesLib/MYODBCDesARD.cpp
MYODBCDes/MYODBCDesLib/MYODBCDesIPD.cpp
MYODBCDes/MYODBCDesLib/MYODBCDesIRD.cpp
MYODBCDes/MYODBCDesLib/MYODBCDesRec.cpp
MYODBCDes/MYODBCDesTest/MYODBCDesTest.cpp
MYODBCDes/MYODBCDesTest/MYODBCDesTest.pro
MYODBCDes/include/MYODBCDes.h
Log:
UNICODE:
- descriptors unit testing working
- more tests need to be added
Modified: MYODBCDes/MYODBCDesLib/MYODBCDes.cpp
===================================================================
--- MYODBCDes/MYODBCDesLib/MYODBCDes.cpp 2006-01-06 23:06:40 UTC (rev 31)
+++ MYODBCDes/MYODBCDesLib/MYODBCDes.cpp 2006-01-07 06:48:25 UTC (rev 32)
@@ -74,10 +74,13 @@
{
MYODBCDbgEnter();
+// while ( !listRecords.isEmpty() )
+// delete listRecords[0];
+
while ( !listRecords.isEmpty() )
- delete listRecords[0];
+ delete listRecords.takeFirst();
- delete pdia;
+// delete pdia;
MYODBCDbgReturn2();
}
@@ -107,9 +110,9 @@
/*
Append record as needed to make nRecNumber valid.
*/
- if ( nRecNumber >= getCount() )
+ if ( nRecNumber > getCount() )
{
- SQLRETURN nReturn = setCount( nRecNumber + 1, true );
+ SQLRETURN nReturn = setCount( nRecNumber, true );
if ( !SQL_SUCCEEDED( nReturn ) )
MYODBCDbgReturn( nReturn );
}
@@ -566,7 +569,7 @@
MYODBCDbgReturn( SQL_SUCCESS );
case SQL_DESC_COUNT:
- *((SQLSMALLINT *)pValuePtr) = getCount() - 1;
+ *((SQLSMALLINT *)pValuePtr) = getCount();
MYODBCDbgReturn( SQL_SUCCESS );
case SQL_DESC_ROWS_PROCESSED_PTR:
@@ -631,7 +634,15 @@
{
MYODBCDbgEnter();
- MYODBCDbgReturn3( "%d", listRecords.count() );
+ /*! \internal ODBC Rule
+
+ This SQLSMALLINT header field specifies the 1-based index of the highest-numbered
+ record that contains data.
+
+ 0 is returned if only the bookmark record exists (this makes the bookmark
+ record something of a hidden record).
+ */
+ MYODBCDbgReturn3( "%d", (listRecords.count() - 1) );
}
SQLUINTEGER *MYODBCDes::getRowsProcessedPtr()
Modified: MYODBCDes/MYODBCDesLib/MYODBCDesAPD.cpp
===================================================================
--- MYODBCDes/MYODBCDesLib/MYODBCDesAPD.cpp 2006-01-06 23:06:40 UTC (rev 31)
+++ MYODBCDes/MYODBCDesLib/MYODBCDesAPD.cpp 2006-01-07 06:48:25 UTC (rev 32)
@@ -13,11 +13,12 @@
by an ODBC 3.x application working with an ODBC 2.x driver
or by an ODBC 2.x application working with an ODBC 3.x
driver.)
- */
+ */
MYODBCDesRecAPD *precord = new MYODBCDesRecAPD( this );
precord->setConciseType( SQL_BINARY );
precord->setType( SQL_BINARY );
precord->setDatetimeIntervalCode( 0 );
+ listRecords.prepend( precord );
}
SQLRETURN MYODBCDesAPD::setDescField( SQLSMALLINT nRecNumber, SQLSMALLINT
nFieldIdentifier, SQLPOINTER pValuePtr, SQLINTEGER nBufferLength )
@@ -101,7 +102,7 @@
IPD: R/W
*/
/* expand/shrink record list; free, even, bound records as needed */
- MYODBCDbgReturn( setCount( (SQLINTEGER)pValuePtr, true ) );
+ MYODBCDbgReturn( setCount( (SQLSMALLINT)pValuePtr, true ) );
case SQL_DESC_ROWS_PROCESSED_PTR:
/*!
@@ -156,19 +157,20 @@
MYODBCDbgReturn( getDia()->doAppend( MYODBC_DIA_07009, 0, NULL ) );
/* append */
- while ( nCount > listRecords.count() )
+ while ( nCount > getCount() )
{
- new MYODBCDesRecAPD( this );
+ MYODBCDesRecAPD *pdesrec = new MYODBCDesRecAPD( this );
+ listRecords.append( pdesrec );
}
/* truncate */
- while ( listRecords.count() > nCount )
+ while ( getCount() > nCount )
{
/* do not delete bound records */
if ( listRecords.last()->getDataPtr() && !bUnbind )
break;
- delete listRecords.last();
+ delete listRecords.takeLast();
}
MYODBCDbgReturn( SQL_SUCCESS );
Modified: MYODBCDes/MYODBCDesLib/MYODBCDesARD.cpp
===================================================================
--- MYODBCDes/MYODBCDesLib/MYODBCDesARD.cpp 2006-01-06 23:06:40 UTC (rev 31)
+++ MYODBCDes/MYODBCDesLib/MYODBCDesARD.cpp 2006-01-07 06:48:25 UTC (rev 32)
@@ -18,6 +18,7 @@
precord->setConciseType( SQL_BINARY );
precord->setType( SQL_BINARY );
precord->setDatetimeIntervalCode( 0 );
+ listRecords.prepend( precord );
}
SQLRETURN MYODBCDesARD::setDescField( SQLSMALLINT nRecNumber, SQLSMALLINT
nFieldIdentifier, SQLPOINTER pValuePtr, SQLINTEGER nBufferLength )
@@ -103,7 +104,7 @@
ARD: R/W
*/
/* expand/shrink record list; free, even, bound records as needed */
- MYODBCDbgReturn( setCount( (SQLINTEGER)pValuePtr, true ) );
+ MYODBCDbgReturn( setCount( (SQLSMALLINT)pValuePtr, true ) );
case SQL_DESC_ROWS_PROCESSED_PTR:
/*!
@@ -150,19 +151,20 @@
MYODBCDbgReturn( getDia()->doAppend( MYODBC_DIA_07009, 0, NULL ) );
/* append */
- while ( nCount > listRecords.count() )
+ while ( nCount > getCount() )
{
- new MYODBCDesRecARD( this );
+ MYODBCDesRecARD *pdesrec = new MYODBCDesRecARD( this );
+ listRecords.append( pdesrec );
}
/* truncate */
- while ( listRecords.count() > nCount )
+ while ( getCount() > nCount )
{
/* do not delete bound records */
if ( listRecords.last()->getDataPtr() && !bUnbind )
break;
- delete listRecords.last();
+ delete listRecords.takeLast();
}
MYODBCDbgReturn( SQL_SUCCESS );
Modified: MYODBCDes/MYODBCDesLib/MYODBCDesIPD.cpp
===================================================================
--- MYODBCDes/MYODBCDesLib/MYODBCDesIPD.cpp 2006-01-06 23:06:40 UTC (rev 31)
+++ MYODBCDes/MYODBCDesLib/MYODBCDesIPD.cpp 2006-01-07 06:48:25 UTC (rev 32)
@@ -18,6 +18,7 @@
precord->setConciseType( SQL_BINARY );
precord->setType( SQL_BINARY );
precord->setDatetimeIntervalCode( 0 );
+ listRecords.prepend( precord );
}
SQLRETURN MYODBCDesIPD::setDescField( SQLSMALLINT nRecNumber, SQLSMALLINT
nFieldIdentifier, SQLPOINTER pValuePtr, SQLINTEGER nBufferLength )
@@ -103,7 +104,7 @@
IPD: R/W
*/
/* expand/shrink record list; free, even, bound records as needed */
- MYODBCDbgReturn( setCount( (SQLINTEGER)pValuePtr, true ) );
+ MYODBCDbgReturn( setCount( (SQLSMALLINT)pValuePtr, true ) );
case SQL_DESC_ROWS_PROCESSED_PTR:
/*!
@@ -153,19 +154,20 @@
MYODBCDbgReturn( getDia()->doAppend( MYODBC_DIA_07009, 0, NULL ) );
/* append */
- while ( nCount > listRecords.count() )
+ while ( nCount > getCount() )
{
- new MYODBCDesRecIPD( this );
+ MYODBCDesRecIPD *pdesrec = new MYODBCDesRecIPD( this );
+ listRecords.append( pdesrec );
}
/* truncate */
- while ( listRecords.count() > nCount )
+ while ( getCount() > nCount )
{
/* do not delete bound records */
if ( listRecords.last()->getDataPtr() && !bUnbind )
break;
- delete listRecords.last();
+ delete listRecords.takeLast();
}
MYODBCDbgReturn( SQL_SUCCESS );
Modified: MYODBCDes/MYODBCDesLib/MYODBCDesIRD.cpp
===================================================================
--- MYODBCDes/MYODBCDesLib/MYODBCDesIRD.cpp 2006-01-06 23:06:40 UTC (rev 31)
+++ MYODBCDes/MYODBCDesLib/MYODBCDesIRD.cpp 2006-01-07 06:48:25 UTC (rev 32)
@@ -18,6 +18,7 @@
precord->setConciseType( SQL_BINARY );
precord->setType( SQL_BINARY );
precord->setDatetimeIntervalCode( 0 );
+ listRecords.prepend( precord );
}
SQLRETURN MYODBCDesIRD::setDescField( SQLSMALLINT nRecNumber, SQLSMALLINT
nFieldIdentifier, SQLPOINTER pValuePtr, SQLINTEGER nBufferLength )
@@ -124,19 +125,20 @@
MYODBCDbgReturn( getDia()->doAppend( MYODBC_DIA_07009, 0, NULL ) );
/* append */
- while ( nCount > listRecords.count() )
+ while ( nCount > getCount() )
{
- new MYODBCDesRecIRD( this );
+ MYODBCDesRecIRD *pdesrec = new MYODBCDesRecIRD( this );
+ listRecords.append( pdesrec );
}
/* truncate */
- while ( listRecords.count() > nCount )
+ while ( getCount() > nCount )
{
/* do not delete bound records */
if ( listRecords.last()->getDataPtr() && !bUnbind )
break;
- delete listRecords.last();
+ delete listRecords.takeLast();
}
MYODBCDbgReturn( SQL_SUCCESS );
Modified: MYODBCDes/MYODBCDesLib/MYODBCDesRec.cpp
===================================================================
--- MYODBCDes/MYODBCDesLib/MYODBCDesRec.cpp 2006-01-06 23:06:40 UTC (rev 31)
+++ MYODBCDes/MYODBCDesLib/MYODBCDesRec.cpp 2006-01-07 06:48:25 UTC (rev 32)
@@ -18,7 +18,7 @@
Q_ASSERT( !pdes );
- pdes->listRecords.append( this );
+ this->pdes = pdes;
MYODBCDbgReturn2();
}
@@ -41,8 +41,6 @@
{
MYODBCDbgEnter();
- pdes->listRecords.removeAll( this );
-
MYODBCDbgReturn2();
}
Modified: MYODBCDes/MYODBCDesTest/MYODBCDesTest.cpp
===================================================================
--- MYODBCDes/MYODBCDesTest/MYODBCDesTest.cpp 2006-01-06 23:06:40 UTC (rev 31)
+++ MYODBCDes/MYODBCDesTest/MYODBCDesTest.cpp 2006-01-07 06:48:25 UTC (rev 32)
@@ -1,197 +1,63 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
+#include <QtTest/QtTest>
#include <MYODBCDes.h>
+#include <MYODBCRtti.h>
-typedef struct tTEST
+class MYODBCDesTest : public QObject
{
- char * name;
- int (*pfunc)();
-} TEST;
+ Q_OBJECT
+public:
+ MYODBCDesTest();
+ ~MYODBCDesTest();
+ MYODBC_RTTI_TYPE nFakeDBC;
+ SQLHANDLE hOwner;
+ MYODBCDesAPD * pdes;
+private slots:
+ void alloc();
+ void countUp();
+};
-/*!
- \brief test5
-
- Ensure that MYODBCDesCount will delete descriptor records
- as needed.
-*/
-int test5()
+MYODBCDesTest::MYODBCDesTest()
{
- MYODBC_RTTI_TYPE nFakeSTM = MYODBC_RTTI_STM;
- SQLHANDLE hOwner = &nFakeSTM;
- MYODBC_DES_PTR pDes = MYODBCDesAlloc( hOwner, MYODBC_RTTI_DES_APD );
- int bReturn = 0;
- MYODBC_C_ULONGLONG nItems = 0;
-
- if ( !pDes )
- return 0;
-
- MYODBCDesCount( pDes, 10, MYODBC_C_FALSE );
- MYODBCArrayGetCount( pDes->hRecords, &nItems );
- if ( nItems != 11 )
- goto test5Exit1;
-
- MYODBCDesCount( pDes, 0, MYODBC_C_FALSE );
- MYODBCArrayGetCount( pDes->hRecords, &nItems );
- if ( nItems != 1 )
- goto test5Exit1;
-
- bReturn = 1;
-
-test5Exit1:
- MYODBCDesFree( pDes );
-
- return bReturn;
+ MYODBCDbgInit( stdout );
+ pdes = NULL;
}
-/*!
- \brief test4
-
- Ensure that MYODBCDesCount will add descriptor records
- as needed.
-*/
-int test4()
+MYODBCDesTest::~MYODBCDesTest()
{
- MYODBC_RTTI_TYPE nFakeSTM = MYODBC_RTTI_STM;
- SQLHANDLE hOwner = &nFakeSTM;
- MYODBC_DES_PTR pDes = MYODBCDesAlloc( hOwner, MYODBC_RTTI_DES_APD );
- int bReturn = 0;
- MYODBC_C_ULONGLONG nItems = 0;
-
- if ( !pDes )
- return 0;
-
- MYODBCDesCount( pDes, 10, MYODBC_C_FALSE );
- MYODBCArrayGetCount( pDes->hRecords, &nItems );
- if ( nItems != 11 )
- goto test4Exit1;
-
- bReturn = 1;
-
-test4Exit1:
- MYODBCDesFree( pDes );
-
- return bReturn;
+ if ( pdes) delete pdes;
+ MYODBCDbgFini();
}
-/*!
- \brief test3
-
- Catch attempt to allocate descriptor when descriptor type
- is not compatible with MYODBC_RTTI_DBC handle type.
-*/
-int test3()
+void MYODBCDesTest::alloc()
{
- MYODBC_RTTI_TYPE nFakeDBC = MYODBC_RTTI_DBC;
- SQLHANDLE hOwner = &nFakeDBC;
- MYODBC_DES_PTR pDes = NULL;
+ nFakeDBC = MYODBC_RTTI_DBC;
+ hOwner = &nFakeDBC;
+ pdes = new MYODBCDesAPD( hOwner );
- pDes = MYODBCDesAlloc( hOwner, MYODBC_RTTI_DES_APD );
- if ( pDes )
- {
- MYODBCDesFree( pDes );
- return 0;
- }
-
- pDes = MYODBCDesAlloc( hOwner, MYODBC_RTTI_DES_IPD );
- if ( pDes )
- {
- MYODBCDesFree( pDes );
- return 0;
- }
-
- pDes = MYODBCDesAlloc( hOwner, MYODBC_RTTI_DES_ARD );
- if ( pDes )
- {
- MYODBCDesFree( pDes );
- return 0;
- }
-
- pDes = MYODBCDesAlloc( hOwner, MYODBC_RTTI_DES_IRD );
- if ( pDes )
- {
- MYODBCDesFree( pDes );
- return 0;
- }
-
- return 1;
+ /* this failing would be bad :... */
+ QVERIFY( pdes );
+ /* whats is max record number we can access... */
+ QVERIFY( pdes->getCount() == 0 );
}
-/*!
- \brief test2
-
- Catch attempt to allocate descriptor when descriptor type
- is not compatible with MYODBC_RTTI_STM handle type.
-*/
-int test2()
+void MYODBCDesTest::countUp()
{
- MYODBC_RTTI_TYPE nFakeSTM = MYODBC_RTTI_STM;
- SQLHANDLE hOwner = &nFakeSTM;
- MYODBC_DES_PTR pDes = MYODBCDesAlloc( hOwner, MYODBC_RTTI_DES_UND );
+ SQLSMALLINT nLastIndex = 5;
+ SQLRETURN nReturn;
- /* we should be NULL */
- if ( pDes )
- {
- MYODBCDesFree( pDes );
- return 0;
- }
-
- return 1;
+ /* try to increase record count... */
+ nReturn = pdes->setDescField( 0, SQL_DESC_COUNT, (SQLPOINTER)nLastIndex,
SQL_IS_SMALLINT );
+ QVERIFY( SQL_SUCCEEDED( nReturn ) );
+ /* read record count... */
+ nReturn = pdes->getDescField( 0, SQL_DESC_COUNT, (SQLPOINTER)&nLastIndex,
SQL_IS_SMALLINT, NULL );
+ QVERIFY( SQL_SUCCEEDED( nReturn ) );
+ /* whats is max record number we can access... */
+ QVERIFY( nLastIndex == 5 );
+ /* whats is max record number we can access... */
+ QVERIFY( pdes->getCount() == 5 );
}
-/*!
- \brief test1
+QTEST_MAIN( MYODBCDesTest )
+#include "MYODBCDesTest.moc"
- Allocate descriptor.
-*/
-int test1()
-{
- MYODBC_RTTI_TYPE nFakeDBC = MYODBC_RTTI_DBC;
- SQLHANDLE hOwner = &nFakeDBC;
- MYODBC_DES_PTR pDes = MYODBCDesAlloc( hOwner, MYODBC_RTTI_DES_UND );
- if ( !pDes )
- return 0;
-
- MYODBCDesFree( pDes );
-
- return 1;
-}
-
-/*!
- \brief main
-
- To add a new test simply create a new function in here
- and then 'register' it by adding another element to the
- 'tests' array.
-*/
-int main()
-{
- TEST tests[6]=
- {
- { "test1", test1 },
- { "test2", test2 },
- { "test3", test3 },
- { "test4", test4 },
- { "test5", test5 },
- { 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: MYODBCDes/MYODBCDesTest/MYODBCDesTest.pro
===================================================================
--- MYODBCDes/MYODBCDesTest/MYODBCDesTest.pro 2006-01-06 23:06:40 UTC (rev 31)
+++ MYODBCDes/MYODBCDesTest/MYODBCDesTest.pro 2006-01-07 06:48:25 UTC (rev 32)
@@ -6,15 +6,17 @@
DESTDIR = ../../bin
include( ../../common.pri )
include( ../../config.pri )
-CONFIG += console
-INCLUDEPATH += ../../MYODBCC/include
-INCLUDEPATH += ../../MYODBCArray/include
-INCLUDEPATH += ../../MYODBCList/include
-INCLUDEPATH += ../../MYODBCRtti/include
-INCLUDEPATH += ../../MYODBCDia/include
+include( ../../defines.pri )
+include( ../../odbc.pri )
+CONFIG += qtestlib
+# CONFIG += console
+INCLUDEPATH += ../../MYODBCC/include
+INCLUDEPATH += ../../MYODBCDbg/include
+INCLUDEPATH += ../../MYODBCDia/include
+INCLUDEPATH += ../../MYODBCRtti/include
INCLUDEPATH += ../include
LIBS += -L../../lib
-LIBS += -lMYODBCDes -lMYODBCDia -lMYODBCArray -lMYODBCC
+LIBS += -lMYODBCDes -lMYODBCDia -lMYODBCDbg
# #########################################################
# FILES
@@ -22,5 +24,5 @@
HEADERS =
SOURCES = \
- MYODBCDesTest.c
+ MYODBCDesTest.cpp
Modified: MYODBCDes/include/MYODBCDes.h
===================================================================
--- MYODBCDes/include/MYODBCDes.h 2006-01-06 23:06:40 UTC (rev 31)
+++ MYODBCDes/include/MYODBCDes.h 2006-01-07 06:48:25 UTC (rev 32)
@@ -121,7 +121,7 @@
virtual SQLRETURN setSchemaName( SQLSMALLINT nRecord, const QString
&stringSchemaName );
virtual SQLRETURN setSearchable( SQLSMALLINT nRecord, SQLSMALLINT nSearchable );
virtual SQLRETURN setTableName( SQLSMALLINT nRecord, const QString
&stringTableName );
- virtual SQLRETURN setType( SQLSMALLINT nRecord, SQLSMALLINT nType ) = 0;
+ virtual SQLRETURN setType( SQLSMALLINT nRecord, SQLSMALLINT nType );
virtual SQLRETURN setTypeName( SQLSMALLINT nRecord, const QString &stringTypeName
);
virtual SQLRETURN setUnnamed( SQLSMALLINT nRecord, SQLSMALLINT nUnnamed );
virtual SQLRETURN setUnsigned( SQLSMALLINT nRecord, SQLSMALLINT nUnsigned );
| Thread |
|---|
| • Connector/ODBC 5 commit: r32 - in MYODBCDes: MYODBCDesLib MYODBCDesTest include | pharvey | 7 Jan |