ReactOS 0.4.15-dev-7942-gd23573b
iofuncs.c File Reference
#include <stdio.h>
#include <wine/test.h>
Include dependency graph for iofuncs.c:

Go to the source code of this file.

Classes

struct  _testData
 

Macros

#define _CRT_NON_CONFORMING_SWPRINTFS
 

Functions

void Test_ofuncs ()
 
void Test_ifuncs ()
 
 START_TEST (iofuncs)
 

Variables

struct _testData ECVTTESTDATA []
 

Macro Definition Documentation

◆ _CRT_NON_CONFORMING_SWPRINTFS

#define _CRT_NON_CONFORMING_SWPRINTFS

Definition at line 12 of file iofuncs.c.

Function Documentation

◆ START_TEST()

START_TEST ( iofuncs  )

Definition at line 95 of file iofuncs.c.

96{
99}
void Test_ifuncs()
Definition: iofuncs.c:82
void Test_ofuncs()
Definition: iofuncs.c:48

◆ Test_ifuncs()

void Test_ifuncs ( )

Definition at line 82 of file iofuncs.c.

83{
84 double var;
85 char cnum[] = "12.3";
86 wchar_t wnum[] = L"12.3";
87
88 /* Test sscanf behaviour */
89 sscanf(cnum, "%lf", &var);
90 ok(var == 12.3, "sscanf double conversion failed: got %f\n", var);
91 swscanf(wnum, L"%lf", &var);
92 ok(var == 12.3, "swscanf double conversion failed: got %f\n", var);
93}
#define ok(value,...)
Definition: atltest.h:57
_Check_return_ _CRTIMP int __cdecl swscanf(_In_z_ const wchar_t *_Src, _In_z_ _Scanf_format_string_ const wchar_t *_Format,...)
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
const char * var
Definition: shader.c:5666
#define L(x)
Definition: ntvdm.h:50

Referenced by START_TEST().

◆ Test_ofuncs()

void Test_ofuncs ( )

Definition at line 48 of file iofuncs.c.

49{
50 int i;
51 char* buf = NULL;
52
53 /* Test exponential format */
54 buf = malloc(30 * sizeof(char));
55 if (buf == NULL)
56 {
57 printf("Memory full, exiting\n");
58 return;
59 }
60 for (i = 0; i < sizeof(ECVTTESTDATA)/sizeof(ECVTTESTDATA[0]); i++)
61 {
62 sprintf(buf, "%-+.*E", ECVTTESTDATA[i].prec, ECVTTESTDATA[i].val);
64 "sprintf exp test %d failed: got %s, expected %s\n",
66 }
67 for (i = 0; i < sizeof(ECVTTESTDATA)/sizeof(ECVTTESTDATA[0]); i++)
68 {
69 sprintf(buf, "%-+.*E", ECVTTESTDATA[i].prec + 2, ECVTTESTDATA[i].val);
71 "sprintf exp +2 prec test %d failed: got %s, expected %s\n",
73 }
74
75 /* Test with negative number to be rounded */
76 sprintf(buf, "%-+.*E", ECVTTESTDATA[18].prec + 2, -ECVTTESTDATA[18].val);
77 ok(!strcmp(buf, "-1.0000E-001"), "Negative number sprintf rounding failed: got %s, expected %s\n",
78 buf, "-1.0000E-001");
79 free(buf);
80}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define printf
Definition: freeldr.h:97
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLfloat * val
Definition: glext.h:7180
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
struct _testData ECVTTESTDATA[]
double __cdecl exp2(double)
#define sprintf(buf, format,...)
Definition: sprintf.c:55
DWORD exp
Definition: msg.c:16058

Referenced by START_TEST().

Variable Documentation

◆ ECVTTESTDATA

struct _testData ECVTTESTDATA[]
Initial value:
=
{
{ 45.0, 2, "+4.50E+001", "+4.5000E+001" },
{ 0.0001, 1, "+1.0E-004", "+1.000E-004" },
{ 0.0001, -10, "+1.000000E-004", "+1.000000E-004" },
{ 0.0001, 10, "+1.0000000000E-004", "+1.000000000000E-004" },
{ -111.0001, 5, "-1.11000E+002", "-1.1100010E+002" },
{ 111.0001, 5, "+1.11000E+002", "+1.1100010E+002" },
{ 3333.3, 2, "+3.33E+003", "+3.3333E+003" },
{ 999999999999.9, 3, "+1.000E+012", "+1.00000E+012" },
{ 0.0, 5, "+0.00000E+000", "+0.0000000E+000" },
{ 0.0, 0, "+0E+000", "+0.00E+000" },
{ 0.0, -1, "+0.000000E+000", "+0.0E+000" },
{ -123.0001, 0, "-1E+002", "-1.23E+002" },
{ -123.0001, -1, "-1.230001E+002", "-1.2E+002" },
{ -123.0001, -2, "-1.230001E+002", "-1E+002" },
{ -123.0001, -3, "-1.230001E+002", "-1.230001E+002" },
{ 99.99, 1, "+1.0E+002", "+9.999E+001" },
{ 0.0063, 2, "+6.30E-003", "+6.3000E-003" },
{ 0.0063, 3, "+6.300E-003", "+6.30000E-003" },
{ 0.09999999996, 2, "+1.00E-001", "+1.0000E-001" },
{ 0.6, 1, "+6.0E-001", "+6.000E-001" },
{ 0.6, 0, "+6E-001", "+6.00E-001" },
{ 0.4, 0, "+4E-001", "+4.00E-001" },
{ 0.49, 0, "+5E-001", "+4.90E-001" },
{ 0.51, 0, "+5E-001", "+5.10E-001" }
}

Referenced by Test_ofuncs().