]>
git.saurik.com Git - wxWidgets.git/blob - src/expat/tests/chardata.c
15 xmlstrlen(const XML_Char
*s
)
26 CharData_Init(CharData
*storage
)
28 assert(storage
!= NULL
);
33 CharData_AppendString(CharData
*storage
, const char *s
)
35 int maxchars
= sizeof(storage
->data
) / sizeof(storage
->data
[0]);
40 if (storage
->count
< 0)
42 if ((len
+ storage
->count
) > maxchars
) {
43 len
= (maxchars
- storage
->count
);
45 if (len
+ storage
->count
< sizeof(storage
->data
)) {
46 memcpy(storage
->data
+ storage
->count
, s
, len
);
47 storage
->count
+= len
;
52 CharData_AppendXMLChars(CharData
*storage
, const XML_Char
*s
, int len
)
56 assert(storage
!= NULL
);
58 maxchars
= sizeof(storage
->data
) / sizeof(storage
->data
[0]);
59 if (storage
->count
< 0)
63 if ((len
+ storage
->count
) > maxchars
) {
64 len
= (maxchars
- storage
->count
);
66 if (len
+ storage
->count
< sizeof(storage
->data
)) {
67 memcpy(storage
->data
+ storage
->count
, s
,
68 len
* sizeof(storage
->data
[0]));
69 storage
->count
+= len
;
74 CharData_CheckString(CharData
*storage
, const char *expected
)
80 assert(storage
!= NULL
);
81 assert(expected
!= NULL
);
82 count
= (storage
->count
< 0) ? 0 : storage
->count
;
83 len
= strlen(expected
);
85 if (sizeof(XML_Char
) == 1)
86 sprintf(buffer
, "wrong number of data characters:"
87 " got %d, expected %d:\n%s", count
, len
, storage
->data
);
90 "wrong number of data characters: got %d, expected %d",
95 if (memcmp(expected
, storage
->data
, len
) != 0) {
96 fail("got bad data bytes");
103 CharData_CheckXMLChars(CharData
*storage
, const XML_Char
*expected
)
106 int len
= xmlstrlen(expected
);
109 assert(storage
!= NULL
);
110 count
= (storage
->count
< 0) ? 0 : storage
->count
;
112 sprintf(buffer
, "wrong number of data characters: got %d, expected %d",
117 if (memcmp(expected
, storage
->data
, len
* sizeof(storage
->data
[0])) != 0) {
118 fail("got bad data bytes");