20 #include "procTypes.h"
21 #include "EXIParser.h"
22 #include "stringManipulate.h"
23 #include "grammarGenerator.h"
25 #define MAX_PATH_LEN 200
29 #define EMPTY_TYPE_SCHEMA "EmptyTypes/emptyTypeSchema-xsd.exi"
30 #define EMPTY_TYPE_DEFAULT "EmptyTypes/emptyTypeTest-def.exi"
31 #define EMPTY_TYPE_STRICT "EmptyTypes/emptyTypeTest-strict.exi"
33 #define OUTPUT_BUFFER_SIZE 2000
44 FILE *infile = (FILE*) stream;
45 return fread(buf, 1, readSize, infile);
48 static void parseSchema(
const char* fileName,
EXIPSchema* schema)
53 size_t pathlen = strlen(dataDir);
56 memcpy(exipath, dataDir, pathlen);
57 exipath[pathlen] =
'/';
58 memcpy(&exipath[pathlen+1], fileName, strlen(fileName)+1);
59 schemaFile = fopen(exipath,
"rb" );
62 fail(
"Unable to open file %s", exipath);
67 fseek(schemaFile, 0, SEEK_END);
68 buffer.
bufLen = ftell(schemaFile) + 1;
69 fseek(schemaFile, 0, SEEK_SET);
72 buffer.
buf = (
char *)malloc(buffer.
bufLen);
76 fail(
"Memory allocation error!");
80 fread(buffer.
buf, buffer.
bufLen, 1, schemaFile);
91 fail(
"\n Error reading schema: %d", tmp_err_code);
100 static errorCode sample_fatalError(
const errorCode code,
const char* msg,
void* app_data)
102 printf(
"\n%3d : FATAL ERROR: %s\n", code, msg);
112 printf(
"\nInvalid namespace!");
121 printf(
"\nInvalid doc: rootElem!");
129 printf(
"\nInvalid doc: nilabElem!");
135 printf(
"\nInvalid decoding startElement!");
151 printf(
"\nInvalid doc: basis!");
160 printf(
"\nInvalid doc: xsi:nill!");
168 printf(
"\nInvalid doc: bass!");
176 printf(
"\nInvalid doc: foo!");
182 printf(
"\nInvalid decoding: attribute!");
198 printf(
"\nInvalid decoding: Ahaa!");
205 printf(
"\nInvalid decoding: fooBass!");
210 printf(
"\nInvalid decoding: stringData!");
221 printf(
"\nInvalid decoding: intData!");
252 pathlen = strlen(dataDir);
253 memcpy(exipath, dataDir, pathlen);
254 exipath[pathlen] =
'/';
257 infile = fopen(exipath,
"rb" );
259 fail(
"Unable to open file %s", exipath);
265 tmp_err_code =
initParser(&testParser, buffer, &parsingData);
266 fail_unless (tmp_err_code ==
EXIP_OK,
"initParser returns an error code %d", tmp_err_code);
282 fail_unless (tmp_err_code ==
EXIP_OK,
"parsing the header returns an error code %d", tmp_err_code);
284 tmp_err_code =
setSchema(&testParser, &schema);
285 fail_unless (tmp_err_code ==
EXIP_OK,
"setSchema() returns an error code %d", tmp_err_code);
324 pathlen = strlen(dataDir);
325 memcpy(exipath, dataDir, pathlen);
326 exipath[pathlen] =
'/';
329 infile = fopen(exipath,
"rb" );
331 fail(
"Unable to open file %s", exipath);
337 tmp_err_code =
initParser(&testParser, buffer, &parsingData);
338 fail_unless (tmp_err_code ==
EXIP_OK,
"initParser returns an error code %d", tmp_err_code);
354 fail_unless (tmp_err_code ==
EXIP_OK,
"parsing the header returns an error code %d", tmp_err_code);
356 tmp_err_code =
setSchema(&testParser, &schema);
357 fail_unless (tmp_err_code ==
EXIP_OK,
"setSchema() returns an error code %d", tmp_err_code);
394 int main (
int argc,
char *argv[])
398 printf(
"ERR: Expected test data directory\n");
403 printf(
"ERR: Test data pathname too long: %u", (
unsigned int) strlen(argv[1]));
417 return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;