List:Commits« Previous MessageNext Message »
From:jbalint Date:October 11 2006 10:14pm
Subject:Connector/ODBC 5 commit: r594 - in trunk/SDK/Installer: Library Tests
View as plain text  
Modified:
   trunk/SDK/Installer/Library/MYODBCIns.cpp
   trunk/SDK/Installer/Tests/MYODBCInsTest.cpp
Log:
Fixed parsing of connect params.
Cleaned up MYODBCIns tests for log messages.
Updated Ins test to fully remove a test driver even if it was previously installed.

Modified: trunk/SDK/Installer/Library/MYODBCIns.cpp
===================================================================
--- trunk/SDK/Installer/Library/MYODBCIns.cpp	2006-10-11 22:04:20 UTC (rev 593)
+++ trunk/SDK/Installer/Library/MYODBCIns.cpp	2006-10-11 22:14:22 UTC (rev 594)
@@ -218,7 +218,9 @@
                 /* end of value? */
                 if ( nState == PARSE_STATE_VALUE )
                 {
-                    if ( !isDelim( stringKeywordValues, nScanChar, &nDelim ) )
+                    /* more chars if it's not the last char or delimiter */
+                    if ( nScanChar + 1 < stringKeywordValues.length() && 
+                            !isDelim( stringKeywordValues, nScanChar, &nDelim ) )
                         break;
                 }
                 else if ( nState == PARSE_STATE_VALUE_BRACED )
@@ -269,6 +271,13 @@
                 if ( phashKeywordValues->contains( stringKeyword ) )
                     break;
 
+                /*
+                    increment nScanChar if this is the last char and not null
+                    so mid() is given the right length
+                */
+                if( nScanChar + 1 == stringKeywordValues.length() && 
+                        stringKeywordValues[nScanChar].unicode() != 0 )
+                    nScanChar++;
                 phashKeywordValues->insert( stringKeyword, stringKeywordValues.mid(
nAnchorChar, nScanChar - nAnchorChar ) );
                 stringKeyword = QString::null;
                 break;
@@ -277,14 +286,14 @@
                 MYODBCDbgReturn3( "%d", false );
         }
 
+        /* have we advanced to end of string */
+        if ( isDelimKeywordValues( stringKeywordValues, nScanChar, nDelim ) )
+            break;
+
         /* terminated a name/value pair */
         if ( isDelimKeywordValue( stringKeywordValues[nScanChar], &nDelim ) )
             nState = PARSE_STATE_NAME_START;
 
-        /* have we advanced to end of string */
-        if ( isDelimKeywordValues( stringKeywordValues, nScanChar, nDelim ) )
-            break;
-
         nScanChar++;
 
     } /* while scan */
@@ -606,6 +615,9 @@
 {
     MYODBCDbgEnter();
 
+    if( nScanChar + 1 >= stringKeywordValues.length() )
+        MYODBCDbgReturn3( "%d", true );
+
     switch ( nDelim )
     {
         case DELIM_BOTH:

Modified: trunk/SDK/Installer/Tests/MYODBCInsTest.cpp
===================================================================
--- trunk/SDK/Installer/Tests/MYODBCInsTest.cpp	2006-10-11 22:04:20 UTC (rev 593)
+++ trunk/SDK/Installer/Tests/MYODBCInsTest.cpp	2006-10-11 22:14:22 UTC (rev 594)
@@ -69,6 +69,7 @@
     WCHAR                   szzAttributes[1024];
     WCHAR *                 pszz = szzAttributes;
     int                     nLength;
+    int                     nActualLength;
 
     /* empty, DELIM_NULL, string length */
     szzAttributes[0] = '\0';
@@ -77,23 +78,27 @@
     QVERIFY( nLength == 0 );
 
     /* DELIM_NULL string - as per ConfigDSN() */
-    wcscpy( pszz, TEXT("DRIVER=my driver") );
-    pszz    += 16; *pszz   = '\0'; pszz++;
-    wcscpy( pszz, TEXT("DSN=my dsn") );
-    pszz    += 10; *pszz   = '\0'; pszz++;
-    wcscpy( pszz, TEXT("DATABASE=my database") );
-    pszz    += 20; *pszz   = '\0'; pszz++; 
-    *pszz   = '\0';
+    pszz += 1 + swprintf( pszz, L"DRIVER=my driver" );
+    pszz += 1 + swprintf( pszz, L"DSN=my dsn" );
+    pszz += 1 + swprintf( pszz, L"DATABASE=my database" );
+    *pszz = 0; // MYODBCC::getKeywordValues() needs two NULLs
 
+    nActualLength = pszz - szzAttributes - 1;
+
     nLength = MYODBCC::getKeywordValuesLength( szzAttributes );
-    QVERIFY( nLength == 48 );
+    QCOMPARE( nLength, nActualLength );
 
-    if ( !MYODBCIns::getKeywordValues( &hashKeywordValues, QString::fromUtf16(
szzAttributes, nLength + 1 ), MYODBCIns::DELIM_NULL ) )
+    if ( !MYODBCIns::getKeywordValues( &hashKeywordValues,
+            QString::fromUtf16( szzAttributes, nLength + 1 ),
+            MYODBCIns::DELIM_NULL ) )
         QFAIL( "getKeywordValues failed" );
-    QVERIFY( hashKeywordValues.count() == 3 );
-    QVERIFY( hashKeywordValues.value( "DRIVER" ) == "my driver" );
-    QVERIFY( hashKeywordValues.value( "DSN" ) == "my dsn" );
-    QVERIFY( hashKeywordValues.value( "DATABASE" ) == "my database" );
+    QCOMPARE( hashKeywordValues.count(), 3 );
+    QCOMPARE( hashKeywordValues.value( "DRIVER" ),
+        QString::fromAscii( "my driver" ) );
+    QCOMPARE( hashKeywordValues.value( "DSN" ),
+        QString::fromAscii( "my dsn" ) );
+    QCOMPARE( hashKeywordValues.value( "DATABASE" ),
+        QString::fromAscii( "my database" ) );
 
     /* does MYODBCInsDataSource load ok? */
     {
@@ -101,9 +106,9 @@
         datasource.setScope( MYODBCInsDataSource::DATASOURCE_SCOPE_BOTH );
         if ( !datasource.setAttributes( hashKeywordValues, true, false ) )
             QFAIL( "setAttributes failed" );
-        QVERIFY( datasource.getDRIVER() == "my driver" );
-        QVERIFY( datasource.getName() == "my dsn" );
-        QVERIFY( datasource.getDATABASE() == "my database" );
+        QCOMPARE( datasource.getDRIVER(), QString::fromAscii( "my driver" ) );
+        QCOMPARE( datasource.getName(), QString::fromAscii( "my dsn" ) );
+        QCOMPARE( datasource.getDATABASE(), QString::fromAscii( "my database" ) );
         QVERIFY( datasource.getDESCRIPTION().isNull() );
     }
 }
@@ -153,11 +158,11 @@
         QStringList stringlist = MYODBCIns::getErrors();
         if ( stringlist.isEmpty() )
         {
-            MYODBCDbgError( "Unknown error writing driver information.%1", "" );
+            MYODBCDbgError( "Unknown error writing driver information.%s", "" );
         }
         else
         {
-            MYODBCDbgError( "%1", stringlist.join( "\n" ) );
+            MYODBCDbgError( "%ls", stringlist.join( "\n" ).utf16() );
         }
         QFAIL( "Failed to register driver" );
     }
@@ -176,11 +181,11 @@
         QStringList stringlist = MYODBCIns::getErrors();
         if ( stringlist.isEmpty() )
         {
-            MYODBCDbgError( "Unknown error reading driver information.%1", "" );
+            MYODBCDbgError( "Unknown error reading driver information.%s", "" );
         }
         else
         {
-            MYODBCDbgError( "%1", stringlist.join( "\n" ) );
+            MYODBCDbgError( "%ls", stringlist.join( "\n" ).utf16() );
         }
         QFAIL( "Failed to verify that driver was registered." );
     }
@@ -214,7 +219,7 @@
 
     if ( stringlistDataSourceNames.contains( TEST_DSN ) )
     {
-        MYODBCDbgError( "%1 already exists.", TEST_DSN );
+        MYODBCDbgError( "%s already exists.", TEST_DSN );
         QFAIL( "Failed to create DSN." );
     }
 
@@ -239,11 +244,11 @@
         QStringList stringlist = MYODBCIns::getErrors();
         if ( stringlist.isEmpty() )
         {
-            MYODBCDbgError( "Unknown error writing data source %1.", TEST_DSN );
+            MYODBCDbgError( "Unknown error writing data source %s.", TEST_DSN );
         }
         else
         {
-            MYODBCDbgError( "%1", stringlist.join( "\n" ) );
+            MYODBCDbgError( "%ls", stringlist.join( "\n" ).utf16() );
         }
         QFAIL( "Failed to create DSN." );
     }
@@ -265,11 +270,11 @@
         QStringList stringlist = MYODBCIns::getErrors();
         if ( stringlist.isEmpty() )
         {
-            MYODBCDbgError( "Unknown error reading data source %1. It may not exist.",
TEST_DSN );
+            MYODBCDbgError( "Unknown error reading data source %s. It may not exist.",
TEST_DSN );
         }
         else
         {
-            MYODBCDbgError( "%1", stringlist.join( "\n" ) );
+            MYODBCDbgError( "%ls", stringlist.join( "\n" ).utf16() );
         }
         QFAIL( "Failed to verify DSN." );
     }
@@ -291,9 +296,10 @@
          datasource.getSTMT() != TEST_STMT ||
          datasource.getUID() != TEST_USER ) 
     {
-        MYODBCDbgError( "Have prepended %1 to file name but data source information is
not the same...", stringDefaultInstallLocation );
-        MYODBCDbgError( "\nWrote:\n%1", stringOutput );
-        MYODBCDbgError( "\nRead :\n%1", stringResult );
+        MYODBCDbgError( "Have prepended %ls to file name but data source "
+            "information is not the same...", stringDefaultInstallLocation.utf16() );
+        MYODBCDbgError( "\nWrote:\n%ls", stringOutput.utf16() );
+        MYODBCDbgError( "\nRead :\n%ls", stringResult.utf16() );
         QFAIL( "Failed to verify DSN." );
     }
 }
@@ -305,11 +311,11 @@
         QStringList stringlist = MYODBCIns::getErrors();
         if ( stringlist.isEmpty() )
         {
-            MYODBCDbgError( "Unknown error while deleting %1.", TEST_DSN );
+            MYODBCDbgError( "Unknown error while deleting %s.", TEST_DSN );
         }
         else
         {
-            MYODBCDbgError( "%1", stringlist.join( "\n" ) );
+            MYODBCDbgError( "%ls", stringlist.join( "\n" ).utf16() );
         }
         QFAIL( "Failed to delete DSN." );
     }
@@ -321,31 +327,34 @@
 
     if ( stringlistDataSourceNames.contains( TEST_DSN ) )
     {
-        MYODBCDbgError( "Failed to delete %1.", TEST_DSN );
+        MYODBCDbgError( "Failed to delete %s.", TEST_DSN );
         QFAIL( "Failed to verify delete DSN." );
     }
 }
 
 void MYODBCInsTest::slotDeregisterDriver()
 {
-    DWORD nUsage = 0;
+    DWORD nUsage = 1;
 
-    if ( !MYODBCInsDriver::doDelete( TEST_DRIVERNAME, true, &nUsage ) )
+    while( nUsage > 0 )
     {
-        QStringList stringlist = MYODBCIns::getErrors();
-        if ( stringlist.isEmpty() )
+        if ( !MYODBCInsDriver::doDelete( TEST_DRIVERNAME, true, &nUsage ) )
         {
-            MYODBCDbgError( "Unknown error while deleting %1.", TEST_DRIVERNAME );
+            QStringList stringlist = MYODBCIns::getErrors();
+            if ( stringlist.isEmpty() )
+            {
+                MYODBCDbgError( "Unknown error while deleting %s.", TEST_DRIVERNAME );
+            }
+            else
+            {
+                MYODBCDbgError( "%ls", stringlist.join( "\n" ).utf16() );
+            }
+            QFAIL( "Failed to deregister driver." );
         }
-        else
-        {
-            MYODBCDbgError( "%1", stringlist.join( "\n" ) );
-        }
-        QFAIL( "Failed to deregister driver." );
+
+        if ( nUsage != 0 )
+            MYODBCDbgWarning( "Usage count should be 0 but is %d.", nUsage );
     }
-
-    if ( nUsage != 0 )
-        MYODBCDbgWarning( "Usage count should be 0 but is %1.", nUsage );
 }
 
 void MYODBCInsTest::slotVerifyDeregisterDriver()
@@ -354,7 +363,7 @@
 
     if ( stringlistDriverNames.contains( TEST_DRIVERNAME ) )
     {
-        MYODBCDbgError( "Failed to delete %1.", TEST_DRIVERNAME );
+        MYODBCDbgError( "Failed to delete %s.", TEST_DRIVERNAME );
         QFAIL( "Failed to verify deregister driver." );
     }
 }

Thread
Connector/ODBC 5 commit: r594 - in trunk/SDK/Installer: Library Testsjbalint12 Oct