2002-04-24 23:16:51 +02:00
|
|
|
/* Unit test suite for the wsprintf functions
|
|
|
|
*
|
|
|
|
* Copyright 2002 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-04-24 23:16:51 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2002-05-23 04:40:07 +02:00
|
|
|
#include "wine/test.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2002-04-24 23:16:51 +02:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
|
2002-12-18 21:51:14 +01:00
|
|
|
static void wsprintfATest(void)
|
2002-04-24 23:16:51 +02:00
|
|
|
{
|
|
|
|
char buf[25];
|
2002-12-18 21:51:14 +01:00
|
|
|
int rc;
|
2002-04-24 23:16:51 +02:00
|
|
|
|
2002-12-18 21:51:14 +01:00
|
|
|
rc=wsprintfA(buf, "%010ld", -1);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(rc == 10, "wsPrintfA length failure: rc=%d error=%d\n",rc,GetLastError());
|
2002-12-18 21:51:14 +01:00
|
|
|
ok((lstrcmpA(buf, "-000000001") == 0),
|
2004-01-23 21:50:35 +01:00
|
|
|
"wsprintfA zero padded negative value failure: buf=[%s]\n",buf);
|
2002-04-24 23:16:51 +02:00
|
|
|
}
|
|
|
|
|
2002-12-18 21:51:14 +01:00
|
|
|
static void wsprintfWTest(void)
|
2002-04-24 23:16:51 +02:00
|
|
|
{
|
2002-12-18 21:51:14 +01:00
|
|
|
static const WCHAR fmt[] = {'%','0','1','0','l','d','\0'};
|
|
|
|
static const WCHAR target[] = {'-','0','0','0','0','0','0','0','0','1', '\0'};
|
2002-04-24 23:16:51 +02:00
|
|
|
WCHAR buf[25];
|
2002-12-18 21:51:14 +01:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc=wsprintfW(buf, fmt, -1);
|
|
|
|
if (rc==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
|
2007-07-03 14:50:06 +02:00
|
|
|
{
|
2009-02-23 10:41:03 +01:00
|
|
|
win_skip("wsprintfW is not implemented\n");
|
2002-12-18 21:51:14 +01:00
|
|
|
return;
|
2007-07-03 14:50:06 +02:00
|
|
|
}
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(rc == 10, "wsPrintfW length failure: rc=%d error=%d\n",rc,GetLastError());
|
2002-12-18 21:51:14 +01:00
|
|
|
ok((lstrcmpW(buf, target) == 0),
|
2004-01-23 21:50:35 +01:00
|
|
|
"wsprintfW zero padded negative value failure\n");
|
2002-04-24 23:16:51 +02:00
|
|
|
}
|
|
|
|
|
2006-05-06 15:18:54 +02:00
|
|
|
/* Test if the CharUpper / CharLower functions return true 16 bit results,
|
2006-05-12 00:06:31 +02:00
|
|
|
if the input is a 16 bit input value. Up to Wine 11-2003 the input value
|
2006-05-06 15:18:54 +02:00
|
|
|
0xff returns 0xffffffff. */
|
|
|
|
|
|
|
|
static void CharUpperTest(void)
|
|
|
|
{
|
2009-01-08 13:11:49 +01:00
|
|
|
INT_PTR i,out,failed;
|
2006-05-06 15:18:54 +02:00
|
|
|
|
|
|
|
failed = 0;
|
|
|
|
for (i=0;i<256;i++)
|
|
|
|
{
|
2009-01-08 13:11:49 +01:00
|
|
|
out = (INT_PTR)CharUpper((LPTSTR)i);
|
2006-05-06 15:18:54 +02:00
|
|
|
/* printf("%0x ",out); */
|
|
|
|
if ((out >> 16) != 0)
|
|
|
|
{
|
|
|
|
failed = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-01-08 13:11:49 +01:00
|
|
|
ok(!failed,"CharUpper failed - 16bit input (0x%0lx) returned 32bit result (0x%0lx)\n",i,out);
|
2006-05-06 15:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void CharLowerTest(void)
|
|
|
|
{
|
2009-01-08 13:11:49 +01:00
|
|
|
INT_PTR i,out,failed;
|
2006-05-06 15:18:54 +02:00
|
|
|
|
|
|
|
failed = 0;
|
|
|
|
for (i=0;i<256;i++)
|
|
|
|
{
|
2009-01-08 13:11:49 +01:00
|
|
|
out = (INT_PTR)CharLower((LPTSTR)i);
|
2006-05-06 15:18:54 +02:00
|
|
|
/* printf("%0x ",out); */
|
|
|
|
if ((out >> 16) != 0)
|
|
|
|
{
|
|
|
|
failed = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-01-08 13:11:49 +01:00
|
|
|
ok(!failed,"CharLower failed - 16bit input (0x%0lx) returned 32bit result (0x%0lx)\n",i,out);
|
2006-05-06 15:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-04-24 23:16:51 +02:00
|
|
|
START_TEST(wsprintf)
|
|
|
|
{
|
2002-12-18 21:51:14 +01:00
|
|
|
wsprintfATest();
|
|
|
|
wsprintfWTest();
|
2006-05-06 15:18:54 +02:00
|
|
|
CharUpperTest();
|
|
|
|
CharLowerTest();
|
2002-04-24 23:16:51 +02:00
|
|
|
}
|