tests: Adapt utf8locale to musl
[libisds.git] / test / offline / isds_DbUserInfo_duplicate.c
blobeaab61ae4bad40bdae349cf0ace1a2a0b3bb942a
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);
60 TEST_INTPTR_DUPLICITY(origin->aifo_ticket, copy->aifo_ticket);
62 PASS_TEST;
66 int main(void) {
68 INIT_TEST("isds_DbUserInfo_duplicate()");
69 if (isds_init())
70 ABORT_UNIT("isds_init() failed");
72 TEST("NULL", test_isds_DbUserInfo_duplicate, NULL);
74 struct isds_DbUserInfo empty;
75 memset(&empty, 0, sizeof(empty));
76 TEST("Empty structure", test_isds_DbUserInfo_duplicate, &empty);
78 /* Full structure */
79 isds_UserType UserType = 2;
80 long int UserPrivils = 3;
81 struct isds_PersonName PersonName = {
82 .pnFirstName = "P1",
83 .pnMiddleName = "P2",
84 .pnLastName = "P3",
85 .pnLastNameAtBirth = "P4"
87 struct isds_Address Address = {
88 .adCity = "A1",
89 .adStreet = "A2",
90 .adNumberInStreet = "A3",
91 .adNumberInMunicipality = "A4",
92 .adZipCode = "A5",
93 .adState = "A6"
95 struct tm BiDate = {
96 .tm_year = 1,
97 .tm_mon = 2,
98 .tm_mday = 3
100 struct isds_DbUserInfo full = {
101 .userID = "1",
102 .userType = &UserType,
103 .userPrivils = &UserPrivils,
104 .personName = &PersonName,
105 .address = &Address,
106 .biDate = &BiDate,
107 .ic = "7",
108 .firmName = "8",
109 .caStreet = "9",
110 .caCity = "10",
111 .caZipCode = "11",
112 .caState = "12",
113 .aifo_ticket = "13"
115 TEST("Full structure", test_isds_DbUserInfo_duplicate, &full);
117 isds_cleanup();
118 SUM_TEST();