diff --git a/rostests/winetests/msvcrt/cpp.c b/rostests/winetests/msvcrt/cpp.c index 106ef73ce27..40e11e17f4f 100644 --- a/rostests/winetests/msvcrt/cpp.c +++ b/rostests/winetests/msvcrt/cpp.c @@ -1034,6 +1034,10 @@ static void test_demangle(void) /* 113 */ {"?f@T@@QAEHQAY1BE@BO@$$CBD@Z", "public: int __thiscall T::f(char const (* const)[20][30])"}, /* 114 */ {"??0?$Foo@U?$vector_c@H$00$01$0?1$0A@$0A@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@$0HPPPPPPP@@mpl@boost@@@@QAE@XZ", "public: __thiscall Foo >::Foo >(void)"}, +/* 115 */ {"?swprintf@@YAHPAGIPBGZZ", "int __cdecl swprintf(unsigned short *,unsigned int,unsigned short const *,...)"}, +/* 116 */ {"?vswprintf@@YAHPAGIPBGPAD@Z", "int __cdecl vswprintf(unsigned short *,unsigned int,unsigned short const *,char *)"}, +/* 117 */ {"?vswprintf@@YAHPA_WIPB_WPAD@Z", "int __cdecl vswprintf(wchar_t *,unsigned int,wchar_t const *,char *)"}, +/* 118 */ {"?swprintf@@YAHPA_WIPB_WZZ", "int __cdecl swprintf(wchar_t *,unsigned int,wchar_t const *,...)"}, }; int i, num_test = (sizeof(test)/sizeof(test[0])); diff --git a/rostests/winetests/msvcrt/file.c b/rostests/winetests/msvcrt/file.c index e164555af57..5afdfcbabec 100644 --- a/rostests/winetests/msvcrt/file.c +++ b/rostests/winetests/msvcrt/file.c @@ -422,6 +422,35 @@ static WCHAR* AtoW( const char* p ) return buffer; } +/* Test reading in text mode when the 512'th character read is \r*/ +static void test_readboundary(void) +{ + FILE *fp; + char buf[513], rbuf[513]; + int i, j; + for (i = 0; i < 511; i++) + { + j = (i%('~' - ' ')+ ' '); + buf[i] = j; + } + buf[511] = '\n'; + buf[512] =0; + fp = fopen("boundary.tst", "wt"); + fwrite(buf, 512,1,fp); + fclose(fp); + fp = fopen("boundary.tst", "rt"); + for(i=0; i<512; i++) + { + fseek(fp,0 , SEEK_CUR); + rbuf[i] = fgetc(fp); + } + rbuf[512] =0; + fclose(fp); + unlink("boundary.tst"); + + ok(strcmp(buf, rbuf) == 0,"CRLF on buffer boundary failure\n"); + } + static void test_fgetc( void ) { char* tempf; @@ -438,6 +467,14 @@ static void test_fgetc( void ) ret = fgetc(tempfh); ok(ich == ret, "Second fgetc expected %x got %x\n", ich, ret); fclose(tempfh); + tempfh = fopen(tempf,"wt"); + fputc('\n', tempfh); + fclose(tempfh); + tempfh = fopen(tempf,"wt"); + setbuf(tempfh, NULL); + ret = fgetc(tempfh); + ok(ret == -1, "Unbuffered fgetc in text mode must failed on \\r\\n\n"); + fclose(tempfh); unlink(tempf); free(tempf); } @@ -800,15 +837,23 @@ static void test_file_write_read( void ) tempfd = _open(tempf,_O_RDONLY|_O_TEXT); /* open in TEXT mode */ _lseek(tempfd, -1, FILE_END); ret = _read(tempfd,btext,LLEN); - ok(ret == 1, "_read expected 1 got bad length: %d\n", ret); + ok(ret == 1 && *btext == '\n', "_read expected 1 got bad length: %d\n", ret); _lseek(tempfd, -2, FILE_END); ret = _read(tempfd,btext,LLEN); ok(ret == 1 && *btext == '\n', "_read expected '\\n' got bad length: %d\n", ret); _lseek(tempfd, -3, FILE_END); + ret = _read(tempfd,btext,1); + ok(ret == 1 && *btext == 'e', "_read expected 'e' got \"%.*s\" bad length: %d\n", ret, btext, ret); + ok(tell(tempfd) == 41, "bad position %u expecting 41\n", tell(tempfd)); + _lseek(tempfd, -3, FILE_END); ret = _read(tempfd,btext,2); ok(ret == 1 && *btext == 'e', "_read expected 'e' got \"%.*s\" bad length: %d\n", ret, btext, ret); ok(tell(tempfd) == 42, "bad position %u expecting 42\n", tell(tempfd)); - _close(tempfd); + _lseek(tempfd, -3, FILE_END); + ret = _read(tempfd,btext,3); + ok(ret == 2 && *btext == 'e', "_read expected 'e' got \"%.*s\" bad length: %d\n", ret, btext, ret); + ok(tell(tempfd) == 43, "bad position %u expecting 43\n", tell(tempfd)); + _close(tempfd); ret = unlink(tempf); ok( ret == 0 ,"Can't unlink '%s': %d\n", tempf, errno); @@ -835,7 +880,23 @@ static void test_file_write_read( void ) "problems with _O_BINARY _write / _O_TEXT _read\n"); _close(tempfd); - ret =_chmod (tempf, _S_IREAD | _S_IWRITE); + /* test _read with single bytes. CR should be skipped and LF pulled in */ + tempfd = _open(tempf,_O_RDONLY|_O_TEXT); /* open in TEXT mode */ + for (i=0; i + +static int (__cdecl *prand_s)(unsigned int *); + +static void init(void) +{ + HMODULE hmod = GetModuleHandleA("msvcrt.dll"); + + prand_s = (void *)GetProcAddress(hmod, "rand_s"); +} + +static void test_rand_s(void) +{ + int ret; + unsigned int rand; + + if (!prand_s) + { + win_skip("rand_s is not available\n"); + return; + } + + errno = EBADF; + ret = prand_s(NULL); + ok(ret == EINVAL, "Expected rand_s to return EINVAL, got %d\n", ret); + ok(errno == EINVAL, "Expected errno to return EINVAL, got %d\n", errno); + + ret = prand_s(&rand); + ok(ret == 0, "Expected rand_s to return 0, got %d\n", ret); +} + +START_TEST(misc) +{ + init(); + + test_rand_s(); +} diff --git a/rostests/winetests/msvcrt/msvcrt.rbuild b/rostests/winetests/msvcrt/msvcrt.rbuild index 1657252b945..12c4a534fdb 100644 --- a/rostests/winetests/msvcrt/msvcrt.rbuild +++ b/rostests/winetests/msvcrt/msvcrt.rbuild @@ -27,6 +27,7 @@ file.c headers.c heap.c + misc.c printf.c scanf.c signal.c diff --git a/rostests/winetests/msvcrt/testlist.c b/rostests/winetests/msvcrt/testlist.c index 4bd436d9dea..80259dff799 100644 --- a/rostests/winetests/msvcrt/testlist.c +++ b/rostests/winetests/msvcrt/testlist.c @@ -13,6 +13,7 @@ extern void func_environ(void); extern void func_file(void); extern void func_headers(void); extern void func_heap(void); +extern void func_misc(void); extern void func_printf(void); extern void func_scanf(void); extern void func_signal(void); @@ -28,6 +29,7 @@ const struct test winetest_testlist[] = { "file", func_file }, { "headers", func_headers }, { "heap", func_heap }, + { "misc", func_misc }, { "printf", func_printf }, { "scanf", func_scanf }, { "signal", func_signal },