aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Dmitry Isaikin <isaikin@corp.mail.ru>2016-02-09 13:48:03 +0300
committerGravatar Dmitry Isaikin <isaikin@corp.mail.ru>2016-02-09 15:53:41 +0300
commitd1e587a9cd06a9cf5f619642ec17506d589c687b (patch)
tree8c5fd1b17ecf9c50753198e9b37a32ffcba2ec0d /tests
parentf9cdd2e6193cddfa405723eb70dda9261b26848d (diff)
Some tests for MessageBuilder::writeToFile
Diffstat (limited to 'tests')
-rw-r--r--tests/test-all.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/test-all.cpp b/tests/test-all.cpp
index 1858bef1..ba79a3ea 100644
--- a/tests/test-all.cpp
+++ b/tests/test-all.cpp
@@ -63,6 +63,16 @@ class TestCallback : public mailcore::Object, public mailcore::OperationCallback
}
};
+static mailcore::String * temporaryFilenameForTest()
+{
+ char tempfile[] = "/tmp/mailcore2-test-XXXXXX";
+ char * result = mktemp(tempfile);
+ if (result == NULL) {
+ return NULL;
+ }
+ return mailcore::String::stringWithFileSystemRepresentation(tempfile);
+}
+
static mailcore::Data * testMessageBuilder()
{
mailcore::Address * address = new mailcore::Address();
@@ -96,7 +106,12 @@ static mailcore::Data * testMessageBuilder()
mailcore::Data * data = msg->data();
MCLog("%s", data->bytes());
-
+
+ mailcore::String *filename = temporaryFilenameForTest();
+ msg->writeToFile(filename);
+ mailcore::Data *fileData = mailcore::Data::dataWithContentsOfFile(filename);
+ MCAssert(data->isEqual(fileData));
+
mailcore::MessageBuilder * msg2 = new mailcore::MessageBuilder(msg);
mailcore::String *htmlBody = msg->htmlBody();
mailcore::String *htmlBody2 = msg2->htmlBody();
@@ -104,7 +119,8 @@ static mailcore::Data * testMessageBuilder()
msg->release();
msg2->release();
-
+ unlink(filename->fileSystemRepresentation());
+
return data;
}