Update of Winetests of non autosynched Dlls. Done by Kamil Horniceck

svn path=/trunk/; revision=33397
This commit is contained in:
Daniel Reimer 2008-05-09 17:35:45 +00:00
parent ad119a417d
commit f108d390f0
139 changed files with 42565 additions and 3849 deletions

View file

@ -15,16 +15,81 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include <limits.h>
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
static const WCHAR foobarW[] = {'f','o','o','b','a','r',0};
static void test_destination_buffer(void)
{
LPSTR buffer;
INT maxsize;
INT needed;
INT len;
SetLastError(0xdeadbeef);
needed = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, NULL, 0, NULL, NULL);
ok( (needed > 0), "returned %d with %u (expected '> 0')\n",
needed, GetLastError());
maxsize = needed*2;
buffer = HeapAlloc(GetProcessHeap(), 0, maxsize);
if (buffer == NULL) return;
maxsize--;
memset(buffer, 'x', maxsize);
buffer[maxsize] = '\0';
SetLastError(0xdeadbeef);
len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, buffer, needed+1, NULL, NULL);
ok( (len > 0), "returned %d with %u and '%s' (expected '> 0')\n",
len, GetLastError(), buffer);
memset(buffer, 'x', maxsize);
buffer[maxsize] = '\0';
SetLastError(0xdeadbeef);
len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, buffer, needed, NULL, NULL);
ok( (len > 0), "returned %d with %u and '%s' (expected '> 0')\n",
len, GetLastError(), buffer);
memset(buffer, 'x', maxsize);
buffer[maxsize] = '\0';
SetLastError(0xdeadbeef);
len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, buffer, needed-1, NULL, NULL);
ok( !len && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
"returned %d with %u and '%s' (expected '0' with "
"ERROR_INSUFFICIENT_BUFFER)\n", len, GetLastError(), buffer);
memset(buffer, 'x', maxsize);
buffer[maxsize] = '\0';
SetLastError(0xdeadbeef);
len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, buffer, 1, NULL, NULL);
ok( !len && (GetLastError() == ERROR_INSUFFICIENT_BUFFER),
"returned %d with %u and '%s' (expected '0' with "
"ERROR_INSUFFICIENT_BUFFER)\n", len, GetLastError(), buffer);
SetLastError(0xdeadbeef);
len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, buffer, 0, NULL, NULL);
ok( (len > 0), "returned %d with %u (expected '> 0')\n",
len, GetLastError());
SetLastError(0xdeadbeef);
len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, NULL, needed, NULL, NULL);
ok( !len && (GetLastError() == ERROR_INVALID_PARAMETER),
"returned %d with %u (expected '0' with "
"ERROR_INVALID_PARAMETER)\n", len, GetLastError());
HeapFree(GetProcessHeap(), 0, buffer);
}
static void test_null_source(void)
{
int len;
@ -34,7 +99,14 @@ static void test_null_source(void)
len = WideCharToMultiByte(CP_ACP, 0, NULL, 0, NULL, 0, NULL, NULL);
GLE = GetLastError();
ok(!len && GLE == ERROR_INVALID_PARAMETER,
"WideCharToMultiByte returned %d with GLE=%ld (expected 0 with ERROR_INVALID_PARAMETER)\n",
"WideCharToMultiByte returned %d with GLE=%u (expected 0 with ERROR_INVALID_PARAMETER)\n",
len, GLE);
SetLastError(0);
len = WideCharToMultiByte(CP_ACP, 0, NULL, -1, NULL, 0, NULL, NULL);
GLE = GetLastError();
ok(!len && GLE == ERROR_INVALID_PARAMETER,
"WideCharToMultiByte returned %d with GLE=%u (expected 0 with ERROR_INVALID_PARAMETER)\n",
len, GLE);
}
@ -53,20 +125,75 @@ static void test_negative_source_length(void)
int len;
char buf[10];
WCHAR bufW[10];
static const WCHAR foobarW[] = {'f','o','o','b','a','r',0};
/* Test, whether any negative source length works as strlen() + 1 */
SetLastError( 0xdeadbeef );
memset(buf,'x',sizeof(buf));
len = WideCharToMultiByte(CP_ACP, 0, foobarW, -2002, buf, 10, NULL, NULL);
ok(len == 7 && !lstrcmpA(buf, "foobar") && GetLastError() == 0xdeadbeef,
"WideCharToMultiByte(-2002): len=%d error=%ld\n",len,GetLastError());
"WideCharToMultiByte(-2002): len=%d error=%u\n", len, GetLastError());
SetLastError( 0xdeadbeef );
memset(bufW,'x',sizeof(bufW));
len = MultiByteToWideChar(CP_ACP, 0, "foobar", -2002, bufW, 10);
ok(len == 7 && !mylstrcmpW(bufW, foobarW) && GetLastError() == 0xdeadbeef,
"MultiByteToWideChar(-2002): len=%d error=%ld\n",len,GetLastError());
"MultiByteToWideChar(-2002): len=%d error=%u\n", len, GetLastError());
SetLastError(0xdeadbeef);
memset(bufW, 'x', sizeof(bufW));
len = MultiByteToWideChar(CP_ACP, 0, "foobar", -1, bufW, 6);
ok(len == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"MultiByteToWideChar(-1): len=%d error=%u\n", len, GetLastError());
}
#define LONGBUFLEN 100000
static void test_negative_dest_length(void)
{
int len, i;
static char buf[LONGBUFLEN];
static WCHAR originalW[LONGBUFLEN];
static char originalA[LONGBUFLEN];
DWORD theError;
/* Test return on -1 dest length */
SetLastError( 0xdeadbeef );
memset(buf,'x',sizeof(buf));
len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, buf, -1, NULL, NULL);
todo_wine {
ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER,
"WideCharToMultiByte(destlen -1): len=%d error=%x\n", len, GetLastError());
}
/* Test return on -1000 dest length */
SetLastError( 0xdeadbeef );
memset(buf,'x',sizeof(buf));
len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, buf, -1000, NULL, NULL);
todo_wine {
ok(len == 0 && GetLastError() == ERROR_INVALID_PARAMETER,
"WideCharToMultiByte(destlen -1000): len=%d error=%x\n", len, GetLastError());
}
/* Test return on INT_MAX dest length */
SetLastError( 0xdeadbeef );
memset(buf,'x',sizeof(buf));
len = WideCharToMultiByte(CP_ACP, 0, foobarW, -1, buf, INT_MAX, NULL, NULL);
ok(len == 7 && !lstrcmpA(buf, "foobar") && GetLastError() == 0xdeadbeef,
"WideCharToMultiByte(destlen INT_MAX): len=%d error=%x\n", len, GetLastError());
/* Test return on INT_MAX dest length and very long input */
SetLastError( 0xdeadbeef );
memset(buf,'x',sizeof(buf));
for (i=0; i < LONGBUFLEN - 1; i++) {
originalW[i] = 'Q';
originalA[i] = 'Q';
}
originalW[LONGBUFLEN-1] = 0;
originalA[LONGBUFLEN-1] = 0;
len = WideCharToMultiByte(CP_ACP, 0, originalW, -1, buf, INT_MAX, NULL, NULL);
theError = GetLastError();
ok(len == LONGBUFLEN && !lstrcmpA(buf, originalA) && theError == 0xdeadbeef,
"WideCharToMultiByte(srclen %d, destlen INT_MAX): len %d error=%x\n", LONGBUFLEN, len, theError);
}
static void test_overlapped_buffers(void)
@ -76,15 +203,17 @@ static void test_overlapped_buffers(void)
char buf[256];
int ret;
lstrcpyW((WCHAR *)(buf + 1), strW);
memcpy((WCHAR *)(buf + 1), strW, sizeof(strW));
ret = WideCharToMultiByte(CP_ACP, 0, (WCHAR *)(buf + 1), -1, buf, sizeof(buf), NULL, NULL);
ok(ret == sizeof(strA), "unexpected ret %d != %d\n", ret, sizeof(strA));
ok(ret == sizeof(strA), "unexpected ret %d\n", ret);
ok(!memcmp(buf, strA, sizeof(strA)), "conversion failed: %s\n", buf);
}
START_TEST(codepage)
{
test_destination_buffer();
test_null_source();
test_negative_source_length();
test_negative_dest_length();
test_overlapped_buffers();
}