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