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