test/map_asn1_test.cc
author Roker <roker@pep-project.org>
Tue, 02 May 2017 08:48:35 +0200
branchENGINE-198
changeset 1741 5bd49bd73192
parent 1513 e7f7e42385b5
permissions -rw-r--r--
add more assertions
vb@1513
     1
// This file is under GNU General Public License 3.0
vb@1513
     2
// see LICENSE.txt
vb@1513
     3
vb@647
     4
#include <iostream>
vb@647
     5
#include <string>
vb@647
     6
#include <cstring>
vb@647
     7
#include <assert.h>
vb@647
     8
#include "map_asn1.h"
vb@647
     9
vb@647
    10
using namespace std;
vb@647
    11
vb@647
    12
int main() {
vb@647
    13
    cout << "\n*** map_asn1_test ***\n\n";
vb@647
    14
vb@647
    15
    cout << "creating new identity...\n";
vb@647
    16
vb@647
    17
    pEp_identity *ident1 = new_identity("vb@dingens.org",
vb@647
    18
            "DB4713183660A12ABAFA7714EBE90D44146F62F4", "42", "Volker Birk");
vb@647
    19
    assert(ident1);
vb@647
    20
    ident1->lang[0] = 'd';
vb@647
    21
    ident1->lang[1] = 'e';
vb@647
    22
    ident1->comm_type = PEP_ct_pEp;
vb@647
    23
vb@647
    24
    cout << "converting identity to ASN.1...\n";
vb@647
    25
vb@654
    26
    Identity_t *ident_asn1 = Identity_from_Struct(ident1, NULL);
vb@647
    27
    assert(ident_asn1);
vb@647
    28
vb@647
    29
    cout << "converting identity from ASN.1...\n";
vb@647
    30
vb@654
    31
    pEp_identity *ident2 = Identity_to_Struct(ident_asn1, NULL);
vb@647
    32
    assert(ident2);
vb@647
    33
vb@647
    34
    assert(strcmp(ident1->address, ident2->address) == 0);
vb@647
    35
    assert(strcmp(ident1->fpr, ident2->fpr) == 0);
vb@647
    36
    assert(strcmp(ident1->user_id, ident2->user_id) == 0);
vb@647
    37
    assert(strcmp(ident1->username, ident2->username) == 0);
vb@647
    38
    assert(ident2->comm_type == PEP_ct_pEp);
vb@647
    39
    assert(strcmp(ident2->lang, "de") == 0);
vb@647
    40
vb@647
    41
    cout << "freeing identities...\n";
vb@647
    42
vb@647
    43
    asn_DEF_Identity.free_struct(&asn_DEF_Identity, ident_asn1, 0);
vb@647
    44
    free_identity(ident1);
vb@647
    45
    free_identity(ident2);
vb@647
    46
vb@647
    47
vb@647
    48
    return 0;
vb@647
    49
}
vb@647
    50