test/message_api_test.cc
changeset 112 d001ca329a48
parent 71 3a036da3e479
child 113 4bee48270834
     1.1 --- a/test/message_api_test.cc	Thu Mar 12 00:58:21 2015 +0100
     1.2 +++ b/test/message_api_test.cc	Sat Mar 14 11:28:14 2015 +0100
     1.3 @@ -18,32 +18,43 @@
     1.4      // message_api test code
     1.5  
     1.6      cout << "creating message…\n";
     1.7 -    pEp_identity * me = new_identity("outlooktest@dingens.org", NULL, "23", "Outlook Test");
     1.8 -    me->me = true;
     1.9 -    identity_list *to = new_identity_list(new_identity("vb@dingens.org", NULL, "42", "Volker Birk"));
    1.10 -    message *msg = new_message(PEP_dir_outgoing, me, to, "hello, world");
    1.11 -    assert(msg);
    1.12 +    pEp_identity * me2 = new_identity("outlooktest@dingens.org", NULL, "23", "Outlook Test");
    1.13 +    me2->me = true;
    1.14 +    identity_list *to2 = new_identity_list(new_identity("vb@dingens.org", NULL, "42", "Volker Birk"));
    1.15 +    message *msg2 = new_message(PEP_dir_outgoing, me2, to2, "hello, world");
    1.16 +    assert(msg2);
    1.17      cout << "message created.\n";
    1.18  
    1.19 +    char *text2;
    1.20 +    PEP_STATUS status2 = mime_encode_message(msg2, &text2);
    1.21 +    assert(status2 == PEP_STATUS_OK);
    1.22 +    assert(text2);
    1.23 +
    1.24 +    cout << "decrypted:\n\n";
    1.25 +    cout << text2 << "\n";
    1.26 +
    1.27 +    free(text2);
    1.28 +
    1.29      cout << "encrypting message as MIME multipart…\n";
    1.30 -    message *enc_msg3;
    1.31 +    message *enc_msg2;
    1.32      cout << "calling encrypt_message()\n";
    1.33 -    PEP_STATUS status3 = encrypt_message(session, msg, NULL, &enc_msg3, PEP_enc_MIME_multipart);
    1.34 -    assert(status3 == PEP_STATUS_OK);
    1.35 -    assert(enc_msg3);
    1.36 +    status2 = encrypt_message(session, msg2, NULL, &enc_msg2, PEP_enc_MIME_multipart);
    1.37 +    assert(status2 == PEP_STATUS_OK);
    1.38 +    assert(enc_msg2);
    1.39      cout << "message encrypted.\n";
    1.40      
    1.41 -    cout << "encrypting message in pieces…\n";
    1.42 -    message *enc_msg4;
    1.43 -    cout << "calling encrypt_message()\n";
    1.44 -    PEP_STATUS status4 = encrypt_message(session, msg, NULL, &enc_msg4, PEP_enc_pieces);
    1.45 -    assert(status4 == PEP_STATUS_OK);
    1.46 -    assert(enc_msg4);
    1.47 -    cout << "message encrypted.\n";
    1.48 +    status2 = mime_encode_message(enc_msg2, &text2);
    1.49 +    assert(status2 == PEP_STATUS_OK);
    1.50 +    assert(text2);
    1.51 +
    1.52 +    cout << "encrypted:\n\n";
    1.53 +    cout << text2 << "\n";
    1.54 +
    1.55 +    free(text2);
    1.56  
    1.57      cout << "freeing messages…\n";
    1.58 -    free_message(msg);
    1.59 -    free_message(enc_msg3);
    1.60 +    free_message(msg2);
    1.61 +    free_message(enc_msg2);
    1.62      cout << "done.\n";
    1.63  
    1.64      cout << "calling release()\n";