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