msvcrt/tests: Use NAN and INFINITY definitions from port.h in printf tests.
This commit is contained in:
parent
46db64ce1b
commit
248bd63b53
|
@ -27,7 +27,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
@ -35,6 +34,27 @@
|
|||
|
||||
#include "wine/test.h"
|
||||
|
||||
static inline float __port_infinity(void)
|
||||
{
|
||||
static const unsigned __inf_bytes = 0x7f800000;
|
||||
return *(const float *)&__inf_bytes;
|
||||
}
|
||||
#define INFINITY __port_infinity()
|
||||
|
||||
static inline float __port_nan(void)
|
||||
{
|
||||
static const unsigned __nan_bytes = 0x7fc00000;
|
||||
return *(const float *)&__nan_bytes;
|
||||
}
|
||||
#define NAN __port_nan()
|
||||
|
||||
static inline float __port_ind(void)
|
||||
{
|
||||
static const unsigned __ind_bytes = 0xffc00000;
|
||||
return *(const float *)&__ind_bytes;
|
||||
}
|
||||
#define IND __port_ind()
|
||||
|
||||
static int (__cdecl *p__vscprintf)(const char *format, __ms_va_list valist);
|
||||
static int (__cdecl *p__vscwprintf)(const wchar_t *format, __ms_va_list valist);
|
||||
static int (__cdecl *p__vsnwprintf_s)(wchar_t *str, size_t sizeOfBuffer,
|
||||
|
@ -82,7 +102,7 @@ static void test_sprintf( void )
|
|||
{
|
||||
char buffer[100];
|
||||
const char *format;
|
||||
double pnumber=789456123, inf, nan;
|
||||
double pnumber=789456123;
|
||||
int x, r;
|
||||
WCHAR wide[] = { 'w','i','d','e',0};
|
||||
|
||||
|
@ -675,38 +695,47 @@ static void test_sprintf( void )
|
|||
r = sprintf(buffer, format, 0x12345);
|
||||
ok(!strcmp(buffer,"2345"), "failed \"%s\"\n", buffer);
|
||||
|
||||
nan = 0.0;
|
||||
inf = 1.0/nan;
|
||||
nan = sqrt(-1);
|
||||
format = "%lf";
|
||||
r = sprintf(buffer, format, nan);
|
||||
r = sprintf(buffer, format, IND);
|
||||
ok(r==9, "r = %d\n", r);
|
||||
ok(!strcmp(buffer, "-1.#IND00"), "failed: \"%s\"\n", buffer);
|
||||
r = sprintf(buffer, format, inf);
|
||||
r = sprintf(buffer, format, NAN);
|
||||
ok(r==8, "r = %d\n", r);
|
||||
ok(!strcmp(buffer, "1.#QNAN0"), "failed: \"%s\"\n", buffer);
|
||||
r = sprintf(buffer, format, INFINITY);
|
||||
ok(r==8, "r = %d\n", r);
|
||||
ok(!strcmp(buffer, "1.#INF00"), "failed: \"%s\"\n", buffer);
|
||||
|
||||
format = "%le";
|
||||
r = sprintf(buffer, format, nan);
|
||||
r = sprintf(buffer, format, IND);
|
||||
ok(r==14, "r = %d\n", r);
|
||||
ok(!strcmp(buffer, "-1.#IND00e+000"), "failed: \"%s\"\n", buffer);
|
||||
r = sprintf(buffer, format, inf);
|
||||
r = sprintf(buffer, format, NAN);
|
||||
ok(r==13, "r = %d\n", r);
|
||||
ok(!strcmp(buffer, "1.#QNAN0e+000"), "failed: \"%s\"\n", buffer);
|
||||
r = sprintf(buffer, format, INFINITY);
|
||||
ok(r==13, "r = %d\n", r);
|
||||
ok(!strcmp(buffer, "1.#INF00e+000"), "failed: \"%s\"\n", buffer);
|
||||
|
||||
format = "%lg";
|
||||
r = sprintf(buffer, format, nan);
|
||||
r = sprintf(buffer, format, IND);
|
||||
ok(r==7, "r = %d\n", r);
|
||||
ok(!strcmp(buffer, "-1.#IND"), "failed: \"%s\"\n", buffer);
|
||||
r = sprintf(buffer, format, inf);
|
||||
r = sprintf(buffer, format, NAN);
|
||||
ok(r==7, "r = %d\n", r);
|
||||
ok(!strcmp(buffer, "1.#QNAN"), "failed: \"%s\"\n", buffer);
|
||||
r = sprintf(buffer, format, INFINITY);
|
||||
ok(r==6, "r = %d\n", r);
|
||||
ok(!strcmp(buffer, "1.#INF"), "failed: \"%s\"\n", buffer);
|
||||
|
||||
format = "%010.2lf";
|
||||
r = sprintf(buffer, format, nan);
|
||||
r = sprintf(buffer, format, IND);
|
||||
ok(r==10, "r = %d\n", r);
|
||||
ok(!strcmp(buffer, "-000001.#J"), "failed: \"%s\"\n", buffer);
|
||||
r = sprintf(buffer, format, inf);
|
||||
r = sprintf(buffer, format, NAN);
|
||||
ok(r==10, "r = %d\n", r);
|
||||
ok(!strcmp(buffer, "0000001.#R"), "failed: \"%s\"\n", buffer);
|
||||
r = sprintf(buffer, format, INFINITY);
|
||||
ok(r==10, "r = %d\n", r);
|
||||
ok(!strcmp(buffer, "0000001.#J"), "failed: \"%s\"\n", buffer);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue