test/mime_test.cc
author vb
Sat, 07 Mar 2015 20:29:13 +0100
changeset 89 aef5a4bc78f3
parent 69 c119ffc3065f
child 94 9ec29aa10b58
permissions -rw-r--r--
...
     1 #include <iostream>
     2 #include <fstream>
     3 #include <string>
     4 #include <assert.h>
     5 #include "mime.h"
     6 
     7 using namespace std;
     8 
     9 int main() {
    10     cout << "\n*** mime_test ***\n\n";
    11 
    12     PEP_SESSION session;
    13     
    14     cout << "calling init()\n";
    15     PEP_STATUS status1 = init(&session);   
    16     assert(status1 == PEP_STATUS_OK);
    17     assert(session);
    18     cout << "init() completed.\n";
    19 
    20     // mime test code
    21 
    22     // testing multipart/alternative
    23 
    24     message *msg2 = new_message(PEP_dir_incoming,
    25             new_identity("vb@dingens.org", NULL, NULL, NULL),
    26             new_identity_list(new_identity("trischa@dingens.org", NULL, NULL, NULL)),
    27             "my sübject");
    28     assert(msg2);
    29     string text2 = "my mèssage to yoü";
    30     msg2->longmsg = strdup(text2.c_str());
    31     string html2 = "<html><body><p>my message to you</p></body></html>";
    32     msg2->longmsg_formatted = strdup(html2.c_str());
    33     assert(msg2->longmsg_formatted);
    34 
    35     cout << "encoding message…\n";
    36     char *result2;
    37     PEP_STATUS status2 = mime_encode_message(msg2, &result2);
    38     assert(result2);
    39     assert(status2 == PEP_STATUS_OK);
    40 
    41     cout << "result:\n";
    42     cout << result2 << "\n";
    43 
    44     free(result2);
    45     free_message(msg2);
    46 
    47     cout << "calling release()\n";
    48     release(session);
    49     return 0;
    50 }
    51