From: Peter Verthez Date: Fri, 22 Nov 2002 21:28:55 +0000 (+0000) Subject: Test program for updates in gom. X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=2ccfaedef455b54f53d9da0936f1a0539d22bfd4;p=gedcom-parse.git Test program for updates in gom. --- diff --git a/t/output/update_gom.ref b/t/output/update_gom.ref new file mode 100644 index 0000000..7e9e620 --- /dev/null +++ b/t/output/update_gom.ref @@ -0,0 +1,55 @@ +ERROR: Error: The input 'België' is not a valid UTF-8 string +ERROR: Error: The input 'België' is not a valid string for the locale +Test succeeded +=== HEADER === +Source: + ID: TEST_UPDATE + Name: (null) + Version: 0.17 + Corporation: + Name: (null) + Address: 0x + Phone 1: (null) + Phone 2: (null) + Phone 3: (null) + Data: + Name: (null) + Date: 0x + Copyright: (null) +Destination: (null) +Date: 0x +Time: (null) +Submitter: + type: 7 + xref: @SUBMITTER@ + object: 0x +Submission: 0x +File name: (null) +Copyright: (null) +Gedcom: + Version: 5.5 + Form: LINEAGE-LINKED +Character set: + Name: ASCII + Version: (null) +Language: (null) +Place hierarchy: (null) +Note: +==== +(null) +==== +User data:0x +=== SUBMITTER (@SUBMITTER@) === +Name: België +Address: 0x +Phone 1: (null) +Phone 2: (null) +Phone 3: (null) +multimedia links: 0x +Language 1: (null) +Language 2: (null) +Language 3: (null) +Record file nr: (null) +Record ID: (null) +change date: 0x +User data:0x diff --git a/t/src/test_updategom b/t/src/test_updategom new file mode 100755 index 0000000..8d01a30 --- /dev/null +++ b/t/src/test_updategom @@ -0,0 +1,15 @@ +#!/bin/sh +# $Id$ +# $Name$ + +builddir=`pwd` +if [ -z "$srcdir" ] +then + srcdir=. +fi + +test_program=updategomtest +test_libs="$builddir/../gedcom/libgedcom.la $builddir/../gom/libgedcom_gom.la" + +. $srcdir/src/test_prologue.sh +. $srcdir/src/test_bulk.sh diff --git a/t/src/update_gom.c b/t/src/update_gom.c new file mode 100644 index 0000000..e7190d0 --- /dev/null +++ b/t/src/update_gom.c @@ -0,0 +1,173 @@ +/* Test program for the Gedcom library. + Copyright (C) 2001, 2002 The Genes Development Team + This file is part of the Gedcom parser library. + Contributed by Peter Verthez , 2001. + + The Gedcom parser library is free software; you can redistribute it + and/or modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The Gedcom parser library is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the Gedcom parser library; if not, write to the + Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* $Id$ */ +/* $Name$ */ + +#include "gedcom.h" +#include "gom.h" +#include "output.h" +#include "dump_gom.h" +#include "portability.h" +#include +#include + +void gedcom_message_handler(Gedcom_msg_type type, char *msg) +{ + if (type == MESSAGE) + output(1, "MESSAGE: "); + else if (type == WARNING) + output(1, "WARNING: "); + else if (type == ERROR) + output(1, "ERROR: "); + output(1, "%s\n", msg); +} + +void show_help () +{ + printf("gedcom-parse test program for libgedcom\n\n"); + printf("Usage: updategomtest [options]\n"); + printf("Options:\n"); + printf(" -h Show this help text\n"); + printf(" -q No output to standard output\n"); + printf(" -o File to generate output to (def. testgedcom.out)\n"); +} + +int test_string_functions() +{ + struct header* head; + struct submitter* subm; + struct xref_value* xref; + char* value; + int conv_fails = 0; + const char* orig_source_id = "GEDCOM_PARSE"; + const char* new_source_id = "TEST_UPDATE"; + const char* new_submitter_name_utf8 = "Belgi\xC3\xAB"; + const char* new_submitter_name_ansi = "Belgi\xEB"; + + head = gom_get_header(); + if (head == NULL) + return 10; + + value = gom_get_string(head->source.id); + if (value == NULL) + return 11; + if (strcmp(value, orig_source_id)) + return 12; + + value = gom_set_string(&head->source.id, new_source_id); + if (value == NULL) + return 13; + if (strcmp(value, new_source_id)) + return 14; + + value = gom_get_string(head->source.id); + if (value == NULL) + return 15; + if (strcmp(value, new_source_id)) + return 16; + + xref = head->submitter; + if (xref == NULL) + return 17; + + subm = gom_get_submitter_by_xref(xref->string); + if (subm == NULL) + return 18; + + value = gom_set_string(&subm->name, new_submitter_name_utf8); + if (value == NULL) + return 19; + if (strcmp(value, new_submitter_name_utf8)) + return 20; + + value = gom_get_string_for_locale(subm->name, &conv_fails); + if (value == NULL) + return 21; + if (!strcmp(value, new_submitter_name_utf8)) + return 22; + if (conv_fails != 1) + return 23; + + value = gom_set_string(&subm->name, new_submitter_name_ansi); + if (value != NULL) + return 24; + + value = gom_set_string_for_locale(&subm->name, new_submitter_name_ansi); + if (value != NULL) + return 25; + + return 0; +} + +int main(int argc, char* argv[]) +{ + int result; + char* outfilename = NULL; + + if (argc > 1) { + int i; + for (i=1; i