renamed the package to libgedcom-dev
[gedcom-parse.git] / t / src / update_gom.c
index 46a990740f3a81d5be6f7ddd782ddcc014c1f647..a4e0b0e4b531582aa1b62d874d744248f6ce60e0 100644 (file)
@@ -213,7 +213,7 @@ int test_date_functions()
   return 0;
 }
 
-int test_record_add_delete_functions()
+int test_add_delete_functions()
 {
   struct family* fam1;
   struct individual *ind1, *ind2, *ind3, *ind4;
@@ -226,12 +226,13 @@ int test_record_add_delete_functions()
   struct user_rec* user1;
   struct xref_value* xr;
   struct xref_list* xrl;
+  struct personal_name* name;
   int result;
   char* value;
   const char* new_nr_of_children = "3";
   const char* note_text = "This is some text";
 
-  fam1 = gom_add_family("@FAM1@");
+  fam1 = gom_new_family("@FAM1@");
   if (!fam1) return 101;
   
   value = gom_set_string(&fam1->nr_of_children, new_nr_of_children);
@@ -240,16 +241,16 @@ int test_record_add_delete_functions()
   if (strcmp(value, new_nr_of_children))
     return 103;
 
-  ind1 = gom_add_individual("@FAM1@");
+  ind1 = gom_new_individual("@FAM1@");
   if (ind1) return 104;
 
-  ind1 = gom_add_individual("@IND1@");
+  ind1 = gom_new_individual("@IND1@");
   if (!ind1) return 105;
 
-  mm1 = gom_add_multimedia("@OBJ1@");
+  mm1 = gom_new_multimedia("@OBJ1@");
   if (!mm1) return 106;
 
-  note1 = gom_add_note("@NOTE1@");
+  note1 = gom_new_note("@NOTE1@");
   if (!note1) return 107;
   
   value = gom_set_string(&note1->text, note_text);
@@ -258,37 +259,37 @@ int test_record_add_delete_functions()
   if (strcmp(value, note_text))
     return 109;
 
-  repo1 = gom_add_repository("@REPO1@");
+  repo1 = gom_new_repository("@REPO1@");
   if (!repo1) return 110;
 
-  sour1 = gom_add_source("@SOUR1@");
+  sour1 = gom_new_source("@SOUR1@");
   if (!sour1) return 111;
 
-  subm2 = gom_add_submitter("@SUBMITTER@");
+  subm2 = gom_new_submitter("@SUBMITTER@");
   if (subm2) return 112;
 
-  subm2 = gom_add_submitter("@SUBM2@");
+  subm2 = gom_new_submitter("@SUBM2@");
   if (!subm2) return 113;
 
-  subn1 = gom_add_submission("@SUBMISSION@");
+  subn1 = gom_new_submission("@SUBMISSION@");
   if (!subn1) return 114;
 
-  user1 = gom_add_user_rec("@USER1@", "WRTAG");
+  user1 = gom_new_user_rec("@USER1@", "WRTAG");
   if (user1) return 115;
 
-  user1 = gom_add_user_rec("@USER1@", "_TAG");
+  user1 = gom_new_user_rec("@USER1@", "_TAG");
   if (!user1) return 116;
 
   xr = gom_set_xref(&(fam1->husband), ind1->xrefstr);
   if (!xr) return 118;
 
-  ind2 = gom_add_individual("@IND2@");
+  ind2 = gom_new_individual("@IND2@");
   if (!ind2) return 119;
 
-  ind3 = gom_add_individual("@IND3@");
+  ind3 = gom_new_individual("@IND3@");
   if (!ind3) return 120;
 
-  ind4 = gom_add_individual("@IND4@");
+  ind4 = gom_new_individual("@IND4@");
   if (!ind4) return 121;
 
   xrl = gom_add_xref(&(fam1->children), ind2->xrefstr);
@@ -300,12 +301,42 @@ int test_record_add_delete_functions()
   xrl = gom_add_xref(&(fam1->children), ind4->xrefstr);
   if (!xrl) return 124;
 
-  result = gom_remove_xref(&(fam1->children), ind3->xrefstr);
+  result = gom_move_xref(MOVE_UP, &(fam1->children), ind4->xrefstr);
   if (result != 0) return 125;
 
-  result = gom_remove_xref(&(fam1->children), ind4->xrefstr);
+  result = gom_move_xref(MOVE_UP, &(fam1->children), ind4->xrefstr);
   if (result != 0) return 126;
 
+  result = gom_move_xref(MOVE_UP, &(fam1->children), ind4->xrefstr);
+  if (result != 0) return 127;
+
+  result = gom_move_xref(MOVE_DOWN, &(fam1->children), ind4->xrefstr);
+  if (result != 0) return 128;
+
+  result = gom_remove_xref(&(fam1->children), ind3->xrefstr);
+  if (result != 0) return 129;
+
+  result = gom_remove_xref(&(fam1->children), ind4->xrefstr);
+  if (result != 0) return 130;
+
+  name = gom_add_new_personal_name(&(ind2->name));
+  if (name == NULL) return 131;
+
+  value = gom_set_string(&(name->name), "Testname");
+  if (value == NULL) return 132;
+
+  name = gom_add_new_personal_name(&(ind2->name));
+  if (name == NULL) return 133;
+
+  value = gom_set_string(&(name->name), "Testname 2");
+  if (value == NULL) return 134;
+
+  result = gom_move_personal_name(MOVE_UP, &(ind2->name), name);
+  if (result != 0) return 135;
+
+  result = gom_remove_personal_name(&(ind2->name), name);
+  if (result != 0) return 136;
+
   output(1, "Intermediate output:\n");
   show_data();
 
@@ -394,7 +425,7 @@ int main(int argc, char* argv[])
   if (result == 0)
     result |= test_date_functions();
   if (result == 0)
-    result |= test_record_add_delete_functions();
+    result |= test_add_delete_functions();
   if (result == 0) {
     output(1, "Test succeeded\n");
   }