X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=t%2Fsrc%2Fupdate_gom.c;h=93224c68aa0806edaaf70c24fcc1ea9c7ba20144;hb=873c320ed054d11625baebb356e67f185cff5685;hp=efe3a014c777dcaa76a1c822f5284ac7c9fcce01;hpb=ba2aacdfb41016cfd5ff9970639dbae964a6e34b;p=gedcom-parse.git diff --git a/t/src/update_gom.c b/t/src/update_gom.c index efe3a01..93224c6 100644 --- a/t/src/update_gom.c +++ b/t/src/update_gom.c @@ -26,6 +26,7 @@ #include "output.h" #include "dump_gom.h" #include "portability.h" +#include "string.h" #include #include @@ -212,6 +213,138 @@ int test_date_functions() return 0; } +int test_record_add_delete_functions() +{ + struct family* fam1; + struct individual *ind1, *ind2, *ind3, *ind4; + struct multimedia* mm1; + struct note* note1; + struct repository* repo1; + struct source* sour1; + struct submitter* subm2; + struct submission* subn1; + struct user_rec* user1; + struct xref_value* xr; + struct xref_list* xrl; + int result; + char* value; + const char* new_nr_of_children = "3"; + const char* note_text = "This is some text"; + + fam1 = gom_add_family("@FAM1@"); + if (!fam1) return 201; + + value = gom_set_string(&fam1->nr_of_children, new_nr_of_children); + if (value == NULL) + return 202; + if (strcmp(value, new_nr_of_children)) + return 203; + + ind1 = gom_add_individual("@FAM1@"); + if (ind1) return 204; + + ind1 = gom_add_individual("@IND1@"); + if (!ind1) return 205; + + mm1 = gom_add_multimedia("@OBJ1@"); + if (!mm1) return 206; + + note1 = gom_add_note("@NOTE1@"); + if (!note1) return 207; + + value = gom_set_string(¬e1->text, note_text); + if (value == NULL) + return 208; + if (strcmp(value, note_text)) + return 209; + + repo1 = gom_add_repository("@REPO1@"); + if (!repo1) return 210; + + sour1 = gom_add_source("@SOUR1@"); + if (!sour1) return 211; + + subm2 = gom_add_submitter("@SUBMITTER@"); + if (subm2) return 212; + + subm2 = gom_add_submitter("@SUBM2@"); + if (!subm2) return 213; + + subn1 = gom_add_submission("@SUBMISSION@"); + if (!subn1) return 214; + + user1 = gom_add_user_rec("@USER1@", "WRTAG"); + if (user1) return 215; + + user1 = gom_add_user_rec("@USER1@", "_TAG"); + if (!user1) return 216; + + xr = gom_set_xref(&(fam1->husband), ind1->xrefstr); + if (!xr) return 218; + + ind2 = gom_add_individual("@IND2@"); + if (!ind2) return 219; + + ind3 = gom_add_individual("@IND3@"); + if (!ind3) return 220; + + ind4 = gom_add_individual("@IND4@"); + if (!ind4) return 221; + + xrl = gom_add_xref(&(fam1->children), ind2->xrefstr); + if (!xrl) return 222; + + xrl = gom_add_xref(&(fam1->children), ind3->xrefstr); + if (!xrl) return 223; + + xrl = gom_add_xref(&(fam1->children), ind4->xrefstr); + if (!xrl) return 224; + + result = gom_remove_xref(&(fam1->children), ind3->xrefstr); + if (result != 0) return 225; + + result = gom_remove_xref(&(fam1->children), ind4->xrefstr); + if (result != 0) return 226; + + output(1, "Intermediate output:\n"); + show_data(); + + result = gom_delete_individual(ind1); + if (result == 0) return 251; + + xr = gom_set_xref(&(fam1->husband), NULL); + if (xr) return 252; + + result = gom_delete_individual(ind1); + if (result != 0) return 253; + + result = gom_delete_family(fam1); + if (result != 0) return 250; + + result = gom_delete_multimedia(mm1); + if (result != 0) return 254; + + result = gom_delete_note(note1); + if (result != 0) return 255; + + result = gom_delete_repository(repo1); + if (result != 0) return 256; + + result = gom_delete_source(sour1); + if (result != 0) return 257; + + result = gom_delete_submitter(subm2); + if (result != 0) return 258; + + result = gom_delete_submission(subn1); + if (result != 0) return 259; + + result = gom_delete_user_rec(user1); + if (result != 0) return 260; + + return 0; +} + int main(int argc, char* argv[]) { int result; @@ -257,6 +390,8 @@ int main(int argc, char* argv[]) result |= test_string_functions(); if (result == 0) result |= test_date_functions(); + if (result == 0) + result |= test_record_add_delete_functions(); if (result == 0) { output(1, "Test succeeded\n"); }