File: isds_PersonName_duplicate.c

package info (click to toggle)
libisds 0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,348 kB
  • ctags: 1,659
  • sloc: ansic: 24,898; sh: 11,772; makefile: 393; xml: 375; sed: 16
file content (52 lines) | stat: -rw-r--r-- 1,463 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "../test.h"
#include "isds.h"
#include <string.h>

static int test_isds_PersonName_duplicate(struct isds_PersonName *origin) {
    struct isds_PersonName *copy = isds_PersonName_duplicate(origin);
    TEST_DESTRUCTOR((void(*)(void *))isds_PersonName_free, &copy);

    if (!origin) {
        if (copy) 
            FAIL_TEST("Duplicate of NULL should be NULL");
        PASS_TEST;
    }

    if (!copy)
        FAIL_TEST("isds_PersonName_duplicate() returned NULL instead of "
                "pointer to copy");

    TEST_STRING_DUPLICITY(origin->pnFirstName, copy->pnFirstName);
    TEST_STRING_DUPLICITY(origin->pnMiddleName, copy->pnMiddleName);
    TEST_STRING_DUPLICITY(origin->pnLastName, copy->pnLastName);
    TEST_STRING_DUPLICITY(origin->pnLastNameAtBirth, copy->pnLastNameAtBirth);

    PASS_TEST;
}


int main(int argc, char **argv) {

    INIT_TEST("isds_PersonName_duplicate()");
    if (isds_init())
        ABORT_UNIT("isds_init() failed");
    
    TEST("NULL", test_isds_PersonName_duplicate, NULL);

    struct isds_PersonName empty;
    memset(&empty, 0, sizeof(empty));
    TEST("Empty structure", test_isds_PersonName_duplicate, &empty);

    /* Full structure */
    struct isds_PersonName full = {
        .pnFirstName = "1",
        .pnMiddleName = "2",
        .pnLastName = "3",
        .pnLastNameAtBirth = "4"
    };

    TEST("Full structure", test_isds_PersonName_duplicate, &full);

    isds_cleanup();
    SUM_TEST();
}