test: Use TEST_TMPTR_DUPLICTY to test birthday structures
[libisds.git] / test / offline / isds_DbUserInfo_duplicate.c
blobeea26ad8609ef611ded2265b6ee31efd16c474a9
1 #include "../test.h"
2 #include "isds.h"
3 #include <string.h>
5 static int test_isds_DbUserInfo_duplicate(struct isds_DbUserInfo *origin) {
6 struct isds_DbUserInfo *copy = isds_DbUserInfo_duplicate(origin);
7 TEST_DESTRUCTOR((void (*)(void *))isds_DbUserInfo_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_DbUserInfo_duplicate() returned NULL instead of "
17 "pointer to copy");
19 TEST_STRING_DUPLICITY(origin->userID, copy->userID);
20 TEST_INTPTR_DUPLICITY(origin->userType, copy->userType);
21 TEST_INTPTR_DUPLICITY(origin->userPrivils, copy->userPrivils);
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 /* Post address */
37 TEST_POINTER_DUPLICITY(origin->address, copy->address);
38 if (origin->address && copy->address) {
39 TEST_STRING_DUPLICITY(origin->address->adCity,
40 copy->address->adCity);
41 TEST_STRING_DUPLICITY(origin->address->adStreet,
42 copy->address->adStreet);
43 TEST_STRING_DUPLICITY(origin->address->adNumberInStreet,
44 copy->address->adNumberInStreet);
45 TEST_STRING_DUPLICITY(origin->address->adNumberInMunicipality,
46 copy->address->adNumberInMunicipality);
47 TEST_STRING_DUPLICITY(origin->address->adZipCode,
48 copy->address->adZipCode);
49 TEST_STRING_DUPLICITY(origin->address->adState,
50 copy->address->adState);
53 TEST_TMPTR_DUPLICITY(origin->biDate, copy->biDate);
54 TEST_INTPTR_DUPLICITY(origin->ic, copy->ic);
55 TEST_INTPTR_DUPLICITY(origin->firmName, copy->firmName);
56 TEST_INTPTR_DUPLICITY(origin->caStreet, copy->caStreet);
57 TEST_INTPTR_DUPLICITY(origin->caCity, copy->caCity);
58 TEST_INTPTR_DUPLICITY(origin->caZipCode, copy->caZipCode);
59 TEST_INTPTR_DUPLICITY(origin->caState, copy->caState);
61 PASS_TEST;
65 int main(int argc, char **argv) {
67 INIT_TEST("isds_DbUserInfo_duplicate()");
68 if (isds_init())
69 ABORT_UNIT("isds_init() failed");
71 TEST("NULL", test_isds_DbUserInfo_duplicate, NULL);
73 struct isds_DbUserInfo empty;
74 memset(&empty, 0, sizeof(empty));
75 TEST("Empty structure", test_isds_DbUserInfo_duplicate, &empty);
77 /* Full structure */
78 isds_UserType UserType = 2;
79 long int UserPrivils = 3;
80 struct isds_PersonName PersonName = {
81 .pnFirstName = "P1",
82 .pnMiddleName = "P2",
83 .pnLastName = "P3",
84 .pnLastNameAtBirth = "P4"
86 struct isds_Address Address = {
87 .adCity = "A1",
88 .adStreet = "A2",
89 .adNumberInStreet = "A3",
90 .adNumberInMunicipality = "A4",
91 .adZipCode = "A5",
92 .adState = "A6"
94 struct tm BiDate = {
95 .tm_year = 1,
96 .tm_mon = 2,
97 .tm_mday = 3
99 struct isds_DbUserInfo full = {
100 .userID = "1",
101 .userType = &UserType,
102 .userPrivils = &UserPrivils,
103 .personName = &PersonName,
104 .address = &Address,
105 .biDate = &BiDate,
106 .ic = "7",
107 .firmName = "8",
108 .caStreet = "9",
109 .caCity = "10",
110 .caZipCode = "11",
111 .caState = "12"
113 TEST("Full structure", test_isds_DbUserInfo_duplicate, &full);
115 isds_cleanup();
116 SUM_TEST();