test/mime_test.cc
author vb
Mon, 23 Feb 2015 16:10:22 +0100
changeset 69 c119ffc3065f
child 89 aef5a4bc78f3
permissions -rw-r--r--
MIME unittest
vb@69
     1
#include <iostream>
vb@69
     2
#include <string>
vb@69
     3
#include <assert.h>
vb@69
     4
#include "mime.h"
vb@69
     5
vb@69
     6
using namespace std;
vb@69
     7
vb@69
     8
int main() {
vb@69
     9
    cout << "\n*** mime_test ***\n\n";
vb@69
    10
vb@69
    11
    PEP_SESSION session;
vb@69
    12
    
vb@69
    13
    cout << "calling init()\n";
vb@69
    14
    PEP_STATUS status1 = init(&session);   
vb@69
    15
    assert(status1 == PEP_STATUS_OK);
vb@69
    16
    assert(session);
vb@69
    17
    cout << "init() completed.\n";
vb@69
    18
vb@69
    19
    // mime test code
vb@69
    20
vb@69
    21
    // testing plain
vb@69
    22
vb@69
    23
    string bla2 = "my message to yöu";
vb@69
    24
    cout << "encoding message…\n";
vb@69
    25
    char *result2;
vb@69
    26
    PEP_STATUS status2 = mime_encode_text(bla2.c_str(), NULL, NULL, &result2);
vb@69
    27
    assert(result2);
vb@69
    28
    assert(status2 == PEP_STATUS_OK);
vb@69
    29
vb@69
    30
    cout << "result:\n";
vb@69
    31
    cout << result2 << "\n";
vb@69
    32
vb@69
    33
    free(result2);
vb@69
    34
vb@69
    35
    // testing multipart/alternative
vb@69
    36
vb@69
    37
    string bla3 = "my message to yöu";
vb@69
    38
    string html3 = "<html><body><p>my message to you</p></body></html>";
vb@69
    39
vb@69
    40
    cout << "encoding message…\n";
vb@69
    41
    char *result3;
vb@69
    42
    PEP_STATUS status3 = mime_encode_text(bla3.c_str(), html3.c_str(), NULL, &result3);
vb@69
    43
    assert(result3);
vb@69
    44
    assert(status3 == PEP_STATUS_OK);
vb@69
    45
vb@69
    46
    cout << "result:\n";
vb@69
    47
    cout << result3 << "\n";
vb@69
    48
vb@69
    49
    free(result3);
vb@69
    50
vb@69
    51
    cout << "calling release()\n";
vb@69
    52
    release(session);
vb@69
    53
    return 0;
vb@69
    54
}
vb@69
    55