.autotest InetMessage

git-svn-id: svn://ultimatepp.org/upp/trunk@7185 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-04-08 08:52:34 +00:00
parent 71c77a8bff
commit 97816e35eb
3 changed files with 5214 additions and 3 deletions

View file

@ -18,17 +18,41 @@ CONSOLE_APP_MAIN
String h = LoadFile(GetDataFile("msg1.txt"));
msg.Read(h);
for(int i = 0; i < msg.GetCount(); i++) {
DLOG("== " << i << " ========== " << msg[i]["content-type"]);
LOG("== " << i << " ========== " << msg[i]["content-type"]);
String body = msg[i].Decode();
DDUMP(body.GetCount());
DUMP(body.GetCount());
if(body.GetCount() < 2000)
DDUMP(body);
DUMP(body);
}
Test(msg, 0, 0);
Test(msg, 1, 121, "Tato zpráva neobsahuje viry ani jiný škodlivý kód - avast! Antivirus je aktivní.");
Test(msg, 3, 911, "Tato zpráva neobsahuje viry ani jiný škodlivý kód -<a href=");
Test(msg, 4, 309891);
DLOG("---------------------------------------------------");
ASSERT(msg.Read(LoadFile(GetDataFile("msg2.txt"))));
Vector< Tuple2<String, int> > test;
for(int i = 0; i < msg.GetCount(); i++) {
String ct = msg[i]["content-type"];
int len = msg[i].Decode().GetCount();
LOG(ct << ", LEN: " << len);
if(len)
test.Add(MakeTuple(ct, len));
if(ct == "message/rfc822") {
InetMessage nmsg;
nmsg.Read(msg[i].Decode());
for(int i = 0; i < nmsg.GetCount(); i++) {
String ct = nmsg[i]["content-type"];
int len = nmsg[i].Decode().GetCount();
LOG(" " << ct << ", LEN: " << len);
if(len)
test.Add(MakeTuple(ct, len));
}
}
}
LOG(test);
ASSERT(AsString(test) == "[(text/plain; charset=\"iso-8859-2\", 799), (text/html; charset=\"iso-8859-2\", 5899), (image/gif; name=\"image001.gif\", 5094), (message/rfc822, 272270), (text/plain; charset=\"windows-1250\", 7821), (text/html; charset=\"windows-1250\", 36236), (image/gif; name=\"image001.gif\", 5094), (application/pdf; name=\"BRN_928C13_003175.pdf\", 156223), (message/rfc822, 20440), (text/plain; charset=\"iso-8859-2\", 1152), (text/html; charset=\"iso-8859-2\", 9553), (image/gif; name=\"image001.gif\", 5094)]");
LOG("============ OK");
}

View file

@ -4,6 +4,7 @@ uses
file
msg1.txt,
msg2.txt,
InetMessage.cpp;
mainconfig

File diff suppressed because it is too large Load diff