X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=t%2Fstandalone.c;h=008b5148144c197a45a545553fe18b91a5366db6;hb=5b6276627db2ebc8a7790213df6a523dc8e04238;hp=3db5eda7af45b2fcb98d3437dba9ac3d7f66354a;hpb=fe2dc3978893f5ef76c12b96947d756c36361b63;p=gedcom-parse.git diff --git a/t/standalone.c b/t/standalone.c index 3db5eda..008b514 100644 --- a/t/standalone.c +++ b/t/standalone.c @@ -32,6 +32,7 @@ #include "utf8-locale.h" #define OUTFILE "testgedcom.out" +#define BOGUS_FILE_NAME "Makefile.am" FILE* outfile = NULL; int quiet = 0; @@ -62,6 +63,7 @@ void show_help () printf(" -da Debug setting: libgedcom + yacc debug messages\n"); printf(" -2 Run the test parse 2 times instead of once\n"); printf(" -3 Run the test parse 3 times instead of once\n"); + printf(" -b Parse a bogus file before parsing the main file\n"); printf(" -q No output to standard output\n"); } @@ -141,9 +143,9 @@ void source_end(Gedcom_ctxt parent, Gedcom_ctxt self, Gedcom_val parsed_value) output(1, "Source context %d in parent %d\n", (int)self, (int)parent); } -Gedcom_ctxt source_date_start(Gedcom_ctxt parent, int level, char *tag, - char* raw_value, - int tag_value, Gedcom_val parsed_value) +Gedcom_ctxt date_start(Gedcom_ctxt parent, int level, char *tag, + char* raw_value, + int tag_value, Gedcom_val parsed_value) { struct date_value dv; Gedcom_ctxt self = (Gedcom_ctxt)((int) parent + 1000); @@ -196,7 +198,8 @@ void subscribe_callbacks() gedcom_subscribe_to_record(REC_USER, rec_start, NULL); gedcom_subscribe_to_element(ELT_HEAD_SOUR, source_start, source_end); gedcom_subscribe_to_element(ELT_SOUR_DATA_EVEN_DATE, - source_date_start, NULL); + date_start, NULL); + gedcom_subscribe_to_element(ELT_SUB_EVT_DATE, date_start, NULL); } void gedcom_message_handler(Gedcom_msg_type type, char *msg) @@ -216,6 +219,7 @@ int main(int argc, char* argv[]) int compat_enabled = 1; int debug_level = 0; int run_times = 1; + int bogus = 0; int result = 0; char* file_name = NULL; @@ -244,6 +248,9 @@ int main(int argc, char* argv[]) else if (!strncmp(argv[i], "-3", 3)) { run_times = 3; } + else if (!strncmp(argv[i], "-b", 3)) { + bogus = 1; + } else if (!strncmp(argv[i], "-q", 3)) { quiet = 1; } @@ -265,8 +272,8 @@ int main(int argc, char* argv[]) exit(1); } - setlocale(LC_ALL, ""); gedcom_init(); + setlocale(LC_ALL, ""); gedcom_set_debug_level(debug_level, NULL); gedcom_set_compat_handling(compat_enabled); gedcom_set_error_handling(mech); @@ -278,6 +285,10 @@ int main(int argc, char* argv[]) if (!outfile) { printf("Could not open %s for appending\n", OUTFILE); } + if (bogus) { + output(0, "\n=== Parsing bogus file %s\n", BOGUS_FILE_NAME); + gedcom_parse_file(BOGUS_FILE_NAME); + } while (run_times-- > 0) { output(0, "\n=== Parsing file %s\n", file_name); result |= gedcom_parse_file(file_name);