test/mime_test.cc
changeset 89 aef5a4bc78f3
parent 69 c119ffc3065f
child 94 9ec29aa10b58
     1.1 --- a/test/mime_test.cc	Wed Mar 04 13:32:07 2015 +0100
     1.2 +++ b/test/mime_test.cc	Sat Mar 07 20:29:13 2015 +0100
     1.3 @@ -1,4 +1,5 @@
     1.4  #include <iostream>
     1.5 +#include <fstream>
     1.6  #include <string>
     1.7  #include <assert.h>
     1.8  #include "mime.h"
     1.9 @@ -18,12 +19,22 @@
    1.10  
    1.11      // mime test code
    1.12  
    1.13 -    // testing plain
    1.14 +    // testing multipart/alternative
    1.15  
    1.16 -    string bla2 = "my message to yöu";
    1.17 +    message *msg2 = new_message(PEP_dir_incoming,
    1.18 +            new_identity("vb@dingens.org", NULL, NULL, NULL),
    1.19 +            new_identity_list(new_identity("trischa@dingens.org", NULL, NULL, NULL)),
    1.20 +            "my sübject");
    1.21 +    assert(msg2);
    1.22 +    string text2 = "my mèssage to yoü";
    1.23 +    msg2->longmsg = strdup(text2.c_str());
    1.24 +    string html2 = "<html><body><p>my message to you</p></body></html>";
    1.25 +    msg2->longmsg_formatted = strdup(html2.c_str());
    1.26 +    assert(msg2->longmsg_formatted);
    1.27 +
    1.28      cout << "encoding message…\n";
    1.29      char *result2;
    1.30 -    PEP_STATUS status2 = mime_encode_text(bla2.c_str(), NULL, NULL, &result2);
    1.31 +    PEP_STATUS status2 = mime_encode_message(msg2, &result2);
    1.32      assert(result2);
    1.33      assert(status2 == PEP_STATUS_OK);
    1.34  
    1.35 @@ -31,22 +42,7 @@
    1.36      cout << result2 << "\n";
    1.37  
    1.38      free(result2);
    1.39 -
    1.40 -    // testing multipart/alternative
    1.41 -
    1.42 -    string bla3 = "my message to yöu";
    1.43 -    string html3 = "<html><body><p>my message to you</p></body></html>";
    1.44 -
    1.45 -    cout << "encoding message…\n";
    1.46 -    char *result3;
    1.47 -    PEP_STATUS status3 = mime_encode_text(bla3.c_str(), html3.c_str(), NULL, &result3);
    1.48 -    assert(result3);
    1.49 -    assert(status3 == PEP_STATUS_OK);
    1.50 -
    1.51 -    cout << "result:\n";
    1.52 -    cout << result3 << "\n";
    1.53 -
    1.54 -    free(result3);
    1.55 +    free_message(msg2);
    1.56  
    1.57      cout << "calling release()\n";
    1.58      release(session);