2007-01-09 17:41:04 +01:00
/*
* Copyright 2007 Bill Medland
*
* This library is free software ; you can redistribute it and / or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation ; either
* version 2.1 of the License , or ( at your option ) any later version .
*
* This library is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
* Lesser General Public License for more details .
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin St , Fifth Floor , Boston , MA 02110 - 1301 , USA
*/
# include <wine/test.h>
# include <stdarg.h>
# include "windef.h"
# include "winbase.h"
# include "odbcinst.h"
2007-01-12 21:48:17 +01:00
static void test_SQLConfigMode ( void )
{
BOOL bool_ret ;
DWORD error_code ;
RETCODE sql_ret ;
UWORD config_mode ;
int i ;
ok ( SQLGetConfigMode ( NULL ) , " SQLGetConfigMode(NULL) should succeed \n " ) ;
bool_ret = SQLGetConfigMode ( & config_mode ) ;
ok ( bool_ret & & config_mode = = ODBC_BOTH_DSN , " Failed to get the initial SQLGetConfigMode or it was not both \n " ) ;
bool_ret = SQLSetConfigMode ( 3 ) ;
sql_ret = SQLInstallerErrorW ( 1 , & error_code , NULL , 0 , NULL ) ;
2007-01-17 17:16:48 +01:00
ok ( ! bool_ret & & sql_ret = = SQL_SUCCESS_WITH_INFO & & error_code = = ODBC_ERROR_INVALID_PARAM_SEQUENCE , " SQLSetConfigMode with invalid argument did not fail correctly \n " ) ;
2007-01-12 21:48:17 +01:00
ok ( ODBC_SYSTEM_DSN = = 2 & & ODBC_USER_DSN = = 1 & & ODBC_BOTH_DSN = = 0 , " SQLSetConfigMode modes not as expected \n " ) ;
for ( i = ODBC_SYSTEM_DSN ; i > = ODBC_BOTH_DSN ; - - i )
{
ok ( SQLSetConfigMode ( ( UWORD ) i ) , " SQLSetConfigMode Failed to set config mode \n " ) ;
bool_ret = SQLGetConfigMode ( & config_mode ) ;
ok ( bool_ret & & config_mode = = i , " Failed to confirm SQLSetConfigMode. \n " ) ;
}
/* And that leaves it correctly on BOTH */
}
2007-01-09 17:41:04 +01:00
static void test_SQLInstallerError ( void )
{
RETCODE sql_ret ;
/* MSDN states that the error number should be between 1 and 8. Passing 0 is an error */
sql_ret = SQLInstallerError ( 0 , NULL , NULL , 0 , NULL ) ;
2007-01-10 20:43:41 +01:00
ok ( sql_ret = = SQL_ERROR , " SQLInstallerError(0...) failed with %d instead of SQL_ERROR \n " , sql_ret ) ;
2007-01-09 17:41:04 +01:00
/* However numbers greater than 8 do not return SQL_ERROR.
* I am currenly unsure as to whether it should return SQL_NO_DATA or " the same as for error 8 " ;
* I have never been able to generate 8 errors to test it
*/
sql_ret = SQLInstallerError ( 65535 , NULL , NULL , 0 , NULL ) ;
ok ( sql_ret = = SQL_NO_DATA , " SQLInstallerError(>8...) failed with %d instead of SQL_NO_DATA \n " , sql_ret ) ;
/* Force an error to work with. This should generate ODBC_ERROR_INVALID_BUFF_LEN */
ok ( ! SQLGetInstalledDrivers ( 0 , 0 , 0 ) , " Failed to force an error for testing \n " ) ;
sql_ret = SQLInstallerError ( 2 , NULL , NULL , 0 , NULL ) ;
ok ( sql_ret = = SQL_NO_DATA , " Too many errors when forcing an error for testing \n " ) ;
/* Null pointers are acceptable in all obvious places */
sql_ret = SQLInstallerError ( 1 , NULL , NULL , 0 , NULL ) ;
2007-01-10 20:43:41 +01:00
ok ( sql_ret = = SQL_SUCCESS_WITH_INFO , " SQLInstallerError(null addresses) failed with %d instead of SQL_SUCCESS_WITH_INFO \n " , sql_ret ) ;
2007-01-09 17:41:04 +01:00
}
START_TEST ( misc )
{
2007-01-12 21:48:17 +01:00
test_SQLConfigMode ( ) ;
2007-01-09 17:41:04 +01:00
test_SQLInstallerError ( ) ;
}