test/mime_test.cc
changeset 69 c119ffc3065f
child 89 aef5a4bc78f3
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/mime_test.cc	Mon Feb 23 16:10:22 2015 +0100
     1.3 @@ -0,0 +1,55 @@
     1.4 +#include <iostream>
     1.5 +#include <string>
     1.6 +#include <assert.h>
     1.7 +#include "mime.h"
     1.8 +
     1.9 +using namespace std;
    1.10 +
    1.11 +int main() {
    1.12 +    cout << "\n*** mime_test ***\n\n";
    1.13 +
    1.14 +    PEP_SESSION session;
    1.15 +    
    1.16 +    cout << "calling init()\n";
    1.17 +    PEP_STATUS status1 = init(&session);   
    1.18 +    assert(status1 == PEP_STATUS_OK);
    1.19 +    assert(session);
    1.20 +    cout << "init() completed.\n";
    1.21 +
    1.22 +    // mime test code
    1.23 +
    1.24 +    // testing plain
    1.25 +
    1.26 +    string bla2 = "my message to yöu";
    1.27 +    cout << "encoding message…\n";
    1.28 +    char *result2;
    1.29 +    PEP_STATUS status2 = mime_encode_text(bla2.c_str(), NULL, NULL, &result2);
    1.30 +    assert(result2);
    1.31 +    assert(status2 == PEP_STATUS_OK);
    1.32 +
    1.33 +    cout << "result:\n";
    1.34 +    cout << result2 << "\n";
    1.35 +
    1.36 +    free(result2);
    1.37 +
    1.38 +    // testing multipart/alternative
    1.39 +
    1.40 +    string bla3 = "my message to yöu";
    1.41 +    string html3 = "<html><body><p>my message to you</p></body></html>";
    1.42 +
    1.43 +    cout << "encoding message…\n";
    1.44 +    char *result3;
    1.45 +    PEP_STATUS status3 = mime_encode_text(bla3.c_str(), html3.c_str(), NULL, &result3);
    1.46 +    assert(result3);
    1.47 +    assert(status3 == PEP_STATUS_OK);
    1.48 +
    1.49 +    cout << "result:\n";
    1.50 +    cout << result3 << "\n";
    1.51 +
    1.52 +    free(result3);
    1.53 +
    1.54 +    cout << "calling release()\n";
    1.55 +    release(session);
    1.56 +    return 0;
    1.57 +}
    1.58 +