ReactOS 0.4.15-dev-7942-gd23573b
tester.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <Strn.h>
Include dependency graph for tester.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int argc  ,
char **  argv 
)

Definition at line 6 of file tester.c.

7{
8 char a[8];
9 char pad1[32];
10 char *b;
11 char c[37];
12 char pad2[23];
13 int i;
14 int len1, len2;
15
16 b = Strncpy(a, "hello", sizeof(a));
17 b = Strncat(b, "world", sizeof(a));
18 printf("1: result=[%s] should be=[%s]\n",
19 b,
20 "hellowo"
21 );
22
23 for (i=0; i<sizeof(c); i++)
24 c[i] = 'X';
25 b = Strncpy(c, "testing", sizeof(c) - 2);
26#if (STRN_ZERO_PAD == 1)
27 for (i=7; i<sizeof(c) - 2; i++) {
28 if (c[i] != '\0') {
29 printf("2: did not clear to end of buffer\n");
30 break;
31 }
32 }
33#endif
34 for (i=sizeof(c) - 2; i<sizeof(c); i++) {
35 if (c[i] != 'X') {
36 printf("2: overwrote buffer\n");
37 break;
38 }
39 }
40
41 for (i=0; i<sizeof(c); i++)
42 c[i] = 'X';
43 b = Strncpy(c, "testing", sizeof(c) - 2);
44 b = Strncat(b, " still", sizeof(c) - 2);
45#if (STRN_ZERO_PAD == 1)
46 for (i=13; i<sizeof(c) - 2; i++) {
47 if (c[i] != '\0') {
48 printf("3: did not clear to end of buffer\n");
49 break;
50 }
51 }
52#endif
53 for (i=sizeof(c) - 2; i<sizeof(c); i++) {
54 if (c[i] != 'X') {
55 printf("3: overwrote buffer\n");
56 break;
57 }
58 }
59
60/*--------------*/
61
62 b = Strnpcpy(a, "hello", sizeof(a));
63 len1 = (int) (b - a);
64 b = Strnpcat(a, "world", sizeof(a));
65 len2 = (int) (b - a);
66 printf("4: result=[%s] should be=[%s] len1=%d len2=%d\n",
67 a,
68 "hellowo",
69 len1,
70 len2
71 );
72
73 for (i=0; i<sizeof(c); i++)
74 c[i] = 'X';
75 b = Strnpcpy(c, "testing", sizeof(c) - 2);
76#if (STRNP_ZERO_PAD == 1)
77 for (i=7; i<sizeof(c) - 2; i++) {
78 if (c[i] != '\0') {
79 printf("5: did not clear to end of buffer\n");
80 break;
81 }
82 }
83#endif
84 for (i=sizeof(c) - 2; i<sizeof(c); i++) {
85 if (c[i] != 'X') {
86 printf("5: overwrote buffer\n");
87 break;
88 }
89 }
90
91 for (i=0; i<sizeof(c); i++)
92 c[i] = 'X';
93 b = Strnpcpy(c, "testing", sizeof(c) - 2);
94 b = Strnpcat(c, " still", sizeof(c) - 2);
95#if (STRNP_ZERO_PAD == 1)
96 for (i=13; i<sizeof(c) - 2; i++) {
97 if (c[i] != '\0') {
98 printf("6: did not clear to end of buffer\n");
99 break;
100 }
101 }
102#endif
103 for (i=sizeof(c) - 2; i<sizeof(c); i++) {
104 if (c[i] != 'X') {
105 printf("6: overwrote buffer\n");
106 break;
107 }
108 }
109
110/*--------------*/
111 {
112 char *str;
113
114 str = NULL;
115 if (Dynscat(&str, "this is a test", 0) == NULL) {
116 printf("7a: fail\n");
117 } else if (strcmp(str, "this is a test") != 0) {
118 printf("7b: fail\n");
119 }
120 free(str);
121
122 str = NULL;
123 if (Dynscat(&str, "this is a test", 0) == NULL) {
124 printf("7c: fail\n");
125 } else if (strcmp(str, "this is a test") != 0) {
126 printf("7d: fail\n");
127 } else if (Dynscat(&str, " ", "", "and", " ", "so is this", 0) == NULL) {
128 printf("7e: fail\n");
129 } else if (strcmp(str, "this is a test and so is this") != 0) {
130 printf("7f: fail\n");
131 }
132 free(str);
133 }
134 exit(0);
135}
char * Dynscat(char **dst,...)
Definition: Dynscat.c:9
char * Strncat(char *const, const char *const, const size_t)
Definition: Strncat.c:13
char * Strncpy(char *const, const char *const, const size_t)
Definition: Strncpy.c:11
char * Strnpcpy(char *const, const char *const, size_t)
Definition: Strnpcpy.c:12
char * Strnpcat(char *const, const char *const, size_t)
Definition: Strnpcat.c:16
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define printf
Definition: freeldr.h:97
const GLubyte * c
Definition: glext.h:8905
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
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
#define c
Definition: ke_i.h:80
#define b
Definition: ke_i.h:79
const WCHAR * str
#define exit(n)
Definition: config.h:202