test/map_asn1_test.cc
author Edouard Tisserant <edouard@pep-project.org>
Mon, 24 Oct 2016 20:44:48 +0200
changeset 1329 876ad7615d75
parent 940 5f0a9d0f0ecd
child 1513 e7f7e42385b5
permissions -rw-r--r--
sync : fix encrypted sync messages not being injected when decrypted from non-sync session
     1 #include <iostream>
     2 #include <string>
     3 #include <cstring>
     4 #include <assert.h>
     5 #include "map_asn1.h"
     6 
     7 using namespace std;
     8 
     9 int main() {
    10     cout << "\n*** map_asn1_test ***\n\n";
    11 
    12     cout << "creating new identity...\n";
    13 
    14     pEp_identity *ident1 = new_identity("vb@dingens.org",
    15             "DB4713183660A12ABAFA7714EBE90D44146F62F4", "42", "Volker Birk");
    16     assert(ident1);
    17     ident1->lang[0] = 'd';
    18     ident1->lang[1] = 'e';
    19     ident1->comm_type = PEP_ct_pEp;
    20 
    21     cout << "converting identity to ASN.1...\n";
    22 
    23     Identity_t *ident_asn1 = Identity_from_Struct(ident1, NULL);
    24     assert(ident_asn1);
    25 
    26     cout << "converting identity from ASN.1...\n";
    27 
    28     pEp_identity *ident2 = Identity_to_Struct(ident_asn1, NULL);
    29     assert(ident2);
    30 
    31     assert(strcmp(ident1->address, ident2->address) == 0);
    32     assert(strcmp(ident1->fpr, ident2->fpr) == 0);
    33     assert(strcmp(ident1->user_id, ident2->user_id) == 0);
    34     assert(strcmp(ident1->username, ident2->username) == 0);
    35     assert(ident2->comm_type == PEP_ct_pEp);
    36     assert(strcmp(ident2->lang, "de") == 0);
    37 
    38     cout << "freeing identities...\n";
    39 
    40     asn_DEF_Identity.free_struct(&asn_DEF_Identity, ident_asn1, 0);
    41     free_identity(ident1);
    42     free_identity(ident2);
    43 
    44 
    45     return 0;
    46 }
    47