Tests for xref functions.
[gedcom-parse.git] / t / src / update_gom.c
index c4152ed7d69b240dd8cd48a85a843142e6a9603f..93224c68aa0806edaaf70c24fcc1ea9c7ba20144 100644 (file)
@@ -216,7 +216,7 @@ int test_date_functions()
 int test_record_add_delete_functions()
 {
   struct family* fam1;
-  struct individual* ind1;
+  struct individual *ind1, *ind2, *ind3, *ind4;
   struct multimedia* mm1;
   struct note* note1;
   struct repository* repo1;
@@ -224,6 +224,8 @@ int test_record_add_delete_functions()
   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";
@@ -277,35 +279,68 @@ int test_record_add_delete_functions()
   user1 = gom_add_user_rec("@USER1@", "_TAG");
   if (!user1) return 216;
 
-  output(0, "Intermediate output:\n");
+  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_family(fam1);
-  if (result != 0) return 217;
+  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 218;
+  if (result != 0) return 253;
+
+  result = gom_delete_family(fam1);
+  if (result != 0) return 250;
 
   result = gom_delete_multimedia(mm1);
-  if (result != 0) return 219;
+  if (result != 0) return 254;
 
   result = gom_delete_note(note1);
-  if (result != 0) return 220;
+  if (result != 0) return 255;
 
   result = gom_delete_repository(repo1);
-  if (result != 0) return 221;
+  if (result != 0) return 256;
 
   result = gom_delete_source(sour1);
-  if (result != 0) return 222;
+  if (result != 0) return 257;
 
   result = gom_delete_submitter(subm2);
-  if (result != 0) return 223;
+  if (result != 0) return 258;
 
   result = gom_delete_submission(subn1);
-  if (result != 0) return 224;
+  if (result != 0) return 259;
 
   result = gom_delete_user_rec(user1);
-  if (result != 0) return 225;
+  if (result != 0) return 260;
   
   return 0;
 }