]> andersk Git - libyaml.git/blame - tests/run-loader.c
debian: Release libyaml 0.2.2-1
[libyaml.git] / tests / run-loader.c
CommitLineData
e27a3c88
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
e27a3c88
KS
9#include <assert.h>
10
11int
12main(int argc, char *argv[])
13{
14 int number;
15
16 if (argc < 2) {
17 printf("Usage: %s file1.yaml ...\n", argv[0]);
18 return 0;
19 }
20
21 for (number = 1; number < argc; number ++)
22 {
23 FILE *file;
24 yaml_parser_t parser;
25 yaml_document_t document;
26 int done = 0;
27 int count = 0;
28 int error = 0;
29
30 printf("[%d] Loading '%s': ", number, argv[number]);
31 fflush(stdout);
32
33 file = fopen(argv[number], "rb");
34 assert(file);
35
36 assert(yaml_parser_initialize(&parser));
37
38 yaml_parser_set_input_file(&parser, file);
39
40 while (!done)
41 {
42 if (!yaml_parser_load(&parser, &document)) {
43 error = 1;
44 break;
45 }
46
47 done = (!yaml_document_get_root_node(&document));
48
49 yaml_document_delete(&document);
50
51 if (!done) count ++;
52 }
53
54 yaml_parser_delete(&parser);
55
56 assert(!fclose(file));
57
58 printf("%s (%d documents)\n", (error ? "FAILURE" : "SUCCESS"), count);
59 }
60
61 return 0;
62}
63
This page took 0.108254 seconds and 5 git commands to generate.