ReactOS 0.4.16-dev-1946-g52006dd
_mbsnbcat.c File Reference
#include <apitest.h>
#include <mbstring.h>
Include dependency graph for _mbsnbcat.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define _mbsnbcat   NULL
 

Typedefs

typedef unsigned char *(__cdeclPFN__mbsncat) (unsigned char *, const unsigned char *, size_t)
 

Functions

VOID mbsncat_PerformTests (_In_ LPSTR fname, _In_opt_ PFN__mbsncat func)
 
 START_TEST (_mbsnbcat)
 

Macro Definition Documentation

◆ _mbsnbcat

#define _mbsnbcat   NULL

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 10 of file _mbsnbcat.c.

Typedef Documentation

◆ PFN__mbsncat

typedef unsigned char *(__cdecl * PFN__mbsncat) (unsigned char *, const unsigned char *, size_t)

Definition at line 12 of file _mbsnbcat.c.

Function Documentation

◆ mbsncat_PerformTests()

VOID mbsncat_PerformTests ( _In_ LPSTR  fname,
_In_opt_ PFN__mbsncat  func 
)

Definition at line 35 of file _mbsncat.c.

36{
37 unsigned char dest[16];
38 const unsigned char first[] = "dinosaur";
39 const unsigned char second[] = "duck";
40 unsigned char *s;
41 BOOL MsVcrt = FALSE, CrtDll = FALSE;
42
43#ifdef TEST_MSVCRT
44 MsVcrt = TRUE;
45#endif
46#ifdef TEST_CRTDLL
47 CrtDll = TRUE;
48#endif
49
50#ifndef TEST_STATIC_CRT
51 if (!func)
52 func = Init(fname);
53#endif
54 if (!func)
55 {
56 skip("Skipping tests, because %s is not available\n", fname);
57 return;
58 }
59
60 /* Test invalid arguments */
61 StartSeh()
62 s = func(NULL, NULL, 0);
64 ok(s == NULL, "Expected %s to return NULL, got %p\n", fname, s);
65
66 StartSeh()
67 s = func(NULL, NULL, 10);
68 EndSeh((CrtDll || (MsVcrt && GetWinVersion() <= 0x502)) ? STATUS_ACCESS_VIOLATION : STATUS_SUCCESS);
69 ok(s == NULL, "Expected %s to return NULL, got %p\n", fname, s);
70
71 memset(dest, 'X', sizeof(dest));
72 StartSeh()
73 s = func(dest, NULL, 0);
75 ok(s == dest, "Expected %s to return dest pointer, got %p\n", fname, s);
76 ok(dest[0] == 'X', "Expected the output buffer to be untouched\n");
77
78 memset(dest, 'X', sizeof(dest));
79 StartSeh()
80 s = func(dest, second, 0);
82 ok(s == dest, "Expected %s to return dest pointer, got %p\n", fname, s);
83 ok(dest[0] == 'X', "Expected the output buffer to be untouched\n");
84
85 memset(dest, 'X', sizeof(dest));
86 s = NULL;
87 StartSeh()
88 s = func(dest, NULL, 10);
89 EndSeh((CrtDll || (MsVcrt && GetWinVersion() <= 0x502)) ? STATUS_ACCESS_VIOLATION : STATUS_SUCCESS);
90 ok(s == NULL, "Expected %s to return NULL, got %p\n", fname, s);
91 ok(dest[0] == 'X', "Expected the output buffer to be untouched\n");
92
93 memset(dest, 'X', sizeof(dest));
94 dest[0] = '\0';
95 StartSeh()
96 s = func(dest, second, sizeof(second));
98 ok(s == dest, "Expected %s to return dest pointer, got %p\n", fname, s);
99 ok(!memcmp(dest, second, sizeof(second)),
100 "Expected the output buffer string to be \"duck\", got '%s'\n", dest);
101
102 /* Test source truncation behavior */
103 memset(dest, 'X', sizeof(dest));
105 s = func(dest, second, 0);
106 ok(s == dest, "Expected %s to return dest pointer, got %p\n", fname, s);
108 "Expected the output buffer string to be \"dinosaur\", got '%s'\n", dest);
109
110 memset(dest, 'X', sizeof(dest));
112 s = func(dest, second, sizeof(second));
113 ok(s == dest, "Expected %s to return dest pointer, got %p\n", fname, s);
114 ok(!memcmp(dest, "dinosaurduck", sizeof("dinosaurduck")),
115 "Expected the output buffer string to be \"dinosaurduck\", got '%s'\n", dest);
116
117 memset(dest, 'X', sizeof(dest));
119 s = func(dest, second, sizeof(second) + 1);
120 ok(s == dest, "Expected %s to return dest pointer, got %p\n", fname, s);
121 ok(!memcmp(dest, "dinosaurduck", sizeof("dinosaurduck")),
122 "Expected the output buffer string to be \"dinosaurduck\", got '%s'\n", dest);
123
124 memset(dest, 'X', sizeof(dest));
126 s = func(dest, second, sizeof(second) - 1);
127 ok(s == dest, "Expected %s to return dest pointer, got %p\n", fname, s);
128 ok(!memcmp(dest, "dinosaurduck", sizeof("dinosaurduck")),
129 "Expected the output buffer string to be \"dinosaurduck\", got '%s'\n", dest);
130
131 memset(dest, 'X', sizeof(dest));
133 s = func(dest, second, sizeof(second) - 2);
134 ok(s == dest, "Expected %s to return dest pointer, got %p\n", fname, s);
135 ok(!memcmp(dest, "dinosaurduc", sizeof("dinosaurduc")),
136 "Expected the output buffer string to be \"dinosaurduc\", got '%s'\n", dest);
137
138 /* Test typical scenario */
139 memset(dest, 'X', sizeof(dest));
141 s = func(dest, second, sizeof(second) - 1);
142 ok(s == dest, "Expected %s to return dest pointer, got %p\n", fname, s);
143 ok(!memcmp(dest, "dinosaurduck", sizeof("dinosaurduck")),
144 "Expected the output buffer string to be \"dinosaurduck\", got '%s'\n", dest);
145
146 /* TODO: Add some distinguishing tests (_mbsncat vs. _mbsnbcat) for concatenating chars vs. bytes,
147 * should probably be done with actual multibyte-character strings. */
148}
BOOLEAN Expected
static USHORT GetWinVersion(VOID)
Definition: _mbsncat.c:29
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define StartSeh()
Definition: apitest.h:93
#define EndSeh(ExpectedStatus)
Definition: apitest.h:99
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
return
Definition: dirsup.c:529
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define STATUS_ACCESS_VIOLATION
GLdouble s
Definition: gl.h:2039
GLenum func
Definition: glext.h:6028
GLdouble n
Definition: glext.h:7729
GLuint buffer
Definition: glext.h:5915
GLsizei const GLvoid * pointer
Definition: glext.h:5848
const GLint * first
Definition: glext.h:5794
GLfloat GLfloat p
Definition: glext.h:8902
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static char * dest
Definition: rtl.c:135
#define memset(x, y, z)
Definition: compat.h:39
#define STATUS_SUCCESS
Definition: shellext.h:65
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( _mbsnbcat  )

Definition at line 16 of file _mbsnbcat.c.

17{
18#ifndef TEST_STATIC_CRT
19 #define _mbsnbcat NULL
20#endif
21 mbsncat_PerformTests("_mbsnbcat", _mbsnbcat);
22}
#define _mbsnbcat
VOID mbsncat_PerformTests(_In_ LPSTR fname, _In_opt_ PFN__mbsncat func)
Definition: _mbsncat.c:35