]> andersk Git - libyaml.git/blame - tests/run-parser.c
debian: Release libyaml 0.2.2-1
[libyaml.git] / tests / run-parser.c
CommitLineData
625fcfe9
KS
1#include <yaml.h>
2
3#include <stdlib.h>
4#include <stdio.h>
01224901
KS
5
6#ifdef NDEBUG
7#undef NDEBUG
8#endif
625fcfe9
KS
9#include <assert.h>
10
11int
12main(int argc, char *argv[])
13{
54815ffd
KS
14 int number;
15
16 if (argc < 2) {
17 printf("Usage: %s file1.yaml ...\n", argv[0]);
625fcfe9
KS
18 return 0;
19 }
625fcfe9 20
54815ffd
KS
21 for (number = 1; number < argc; number ++)
22 {
23 FILE *file;
24 yaml_parser_t parser;
25 yaml_event_t event;
26 int done = 0;
27 int count = 0;
28 int error = 0;
625fcfe9 29
54815ffd
KS
30 printf("[%d] Parsing '%s': ", number, argv[number]);
31 fflush(stdout);
625fcfe9 32
54815ffd
KS
33 file = fopen(argv[number], "rb");
34 assert(file);
625fcfe9 35
54815ffd 36 assert(yaml_parser_initialize(&parser));
625fcfe9 37
54815ffd 38 yaml_parser_set_input_file(&parser, file);
625fcfe9 39
54815ffd
KS
40 while (!done)
41 {
42 if (!yaml_parser_parse(&parser, &event)) {
43 error = 1;
44 break;
45 }
625fcfe9 46
54815ffd 47 done = (event.type == YAML_STREAM_END_EVENT);
625fcfe9 48
54815ffd 49 yaml_event_delete(&event);
625fcfe9 50
54815ffd
KS
51 count ++;
52 }
53
54 yaml_parser_delete(&parser);
55
56 assert(!fclose(file));
57
58 printf("%s (%d events)\n", (error ? "FAILURE" : "SUCCESS"), count);
59 }
625fcfe9
KS
60
61 return 0;
62}
63
This page took 0.05724 seconds and 5 git commands to generate.