test: Fix indentation
[libisds.git] / test / offline / isds_DbOwnerInfo_duplicate.c
blob723b6460910612ee3d59df20d858145227073b53
1 #include "../test.h"
2 #include "isds.h"
3 #include <string.h>
5 static int test_isds_DbOwnerInfo_duplicate(struct isds_DbOwnerInfo *origin) {
6 struct isds_DbOwnerInfo *copy = isds_DbOwnerInfo_duplicate(origin);
7 TEST_DESTRUCTOR((void(*)(void*))isds_DbOwnerInfo_free, &copy);
9 if (!origin) {
10 if (copy)
11 FAIL_TEST("Duplicate of NULL should be NULL");
12 PASS_TEST;
15 if (!copy)
16 FAIL_TEST("isds_DbOwnerInfo_duplicate() returned NULL instead of "
17 "pointer to copy");
19 TEST_STRING_DUPLICITY(origin->dbID, copy->dbID);
20 TEST_INTPTR_DUPLICITY(origin->dbType, copy->dbType);
21 TEST_STRING_DUPLICITY(origin->ic, copy->ic);
23 /* Name of person */
24 TEST_POINTER_DUPLICITY(origin->personName, copy->personName);
25 if (origin->personName && copy->personName) {
26 TEST_STRING_DUPLICITY(origin->personName->pnFirstName,
27 copy->personName->pnFirstName);
28 TEST_STRING_DUPLICITY(origin->personName->pnMiddleName,
29 copy->personName->pnMiddleName);
30 TEST_STRING_DUPLICITY(origin->personName->pnLastName,
31 copy->personName->pnLastName);
32 TEST_STRING_DUPLICITY(origin->personName->pnLastNameAtBirth,
33 copy->personName->pnLastNameAtBirth);
36 /* Birth of person */
37 TEST_POINTER_DUPLICITY(origin->birthInfo, copy->birthInfo);
38 if(origin->birthInfo && copy->birthInfo) {
39 TEST_TMPTR_DUPLICITY(origin->birthInfo->biDate,
40 copy->birthInfo->biDate);
41 TEST_STRING_DUPLICITY(origin->birthInfo->biCity,
42 copy->birthInfo->biCity);
43 TEST_STRING_DUPLICITY(origin->birthInfo->biCounty,
44 copy->birthInfo->biCounty);
45 TEST_STRING_DUPLICITY(origin->birthInfo->biState,
46 copy->birthInfo->biState);
49 /* Post address */
50 TEST_POINTER_DUPLICITY(origin->address, copy->address);
51 if (origin->address && copy->address) {
52 TEST_STRING_DUPLICITY(origin->address->adCity,
53 copy->address->adCity);
54 TEST_STRING_DUPLICITY(origin->address->adStreet,
55 copy->address->adStreet);
56 TEST_STRING_DUPLICITY(origin->address->adNumberInStreet,
57 copy->address->adNumberInStreet);
58 TEST_STRING_DUPLICITY(origin->address->adNumberInMunicipality,
59 copy->address->adNumberInMunicipality);
60 TEST_STRING_DUPLICITY(origin->address->adZipCode,
61 copy->address->adZipCode);
62 TEST_STRING_DUPLICITY(origin->address->adState,
63 copy->address->adState);
66 TEST_STRING_DUPLICITY(origin->nationality, copy->nationality);
67 TEST_STRING_DUPLICITY(origin->email, copy->email);
68 TEST_STRING_DUPLICITY(origin->telNumber, copy->telNumber);
69 TEST_STRING_DUPLICITY(origin->identifier, copy->identifier);
70 TEST_STRING_DUPLICITY(origin->registryCode, copy->registryCode);
71 TEST_INTPTR_DUPLICITY(origin->dbState, copy->dbState);
72 TEST_BOOLEANPTR_DUPLICITY(origin->dbEffectiveOVM, copy->dbEffectiveOVM);
73 TEST_BOOLEANPTR_DUPLICITY(origin->dbOpenAddressing, copy->dbOpenAddressing);
75 PASS_TEST;
79 int main(void) {
81 INIT_TEST("isds_DbOwnerInfo_duplicate()");
82 if (isds_init())
83 ABORT_UNIT("isds_init() failed");
85 TEST("NULL", test_isds_DbOwnerInfo_duplicate, NULL);
87 struct isds_DbOwnerInfo empty;
88 memset(&empty, 0, sizeof(empty));
89 TEST("Empty structure", test_isds_DbOwnerInfo_duplicate, &empty);
91 /* Full structure */
92 isds_DbType dbType = 2;
93 struct isds_PersonName PersonName = {
94 .pnFirstName = "P1",
95 .pnMiddleName = "P2",
96 .pnLastName = "P3",
97 .pnLastNameAtBirth = "P4"
99 struct tm BiDate = {
100 .tm_year = 1,
101 .tm_mon = 2,
102 .tm_mday = 3
104 struct isds_BirthInfo BirthInfo = {
105 .biDate = &BiDate,
106 .biCity = "B2",
107 .biCounty = "B3",
108 .biState = "B4"
110 struct isds_Address Address = {
111 .adCity = "A1",
112 .adStreet = "A2",
113 .adNumberInStreet = "A3",
114 .adNumberInMunicipality = "A4",
115 .adZipCode = "A5",
116 .adState = "A6"
118 long int DbState = 13;
119 _Bool DbEffectiveOVM = 1;
120 _Bool DbOpenAddressing = 1;
121 struct isds_DbOwnerInfo full = {
122 .dbID = "1",
123 .dbType = &dbType,
124 .ic = "3",
125 .personName = &PersonName,
126 .firmName = "5",
127 .birthInfo = &BirthInfo,
128 .address = &Address,
129 .nationality = "8",
130 .email = "9",
131 .telNumber = "10",
132 .identifier = "11",
133 .registryCode = "12",
134 .dbState = &DbState,
135 .dbEffectiveOVM = &DbEffectiveOVM,
136 .dbOpenAddressing = &DbOpenAddressing
138 TEST("Full structure", test_isds_DbOwnerInfo_duplicate, &full);
140 isds_cleanup();
141 SUM_TEST();