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