summaryrefslogtreecommitdiffstats
path: root/tdeioslave/smtp/test_headergeneration.cc
blob: 83d999c4a9ba129110fdc539eb6d225d074c5f26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "request.h"

//#include <iostream>

//using std::cout;
//using std::endl;

int main( int , char ** ) {
  static TQCString expected =
    "From: mutz@kde.org\r\n"
    "Subject: missing subject\r\n"
    "To: joe@user.org,\r\n"
    "\tvalentine@14th.february.org\r\n"
    "Cc: boss@example.com\r\n"
    "\n"
    "From: Marc Mutz <mutz@kde.org>\r\n"
    "Subject: missing subject\r\n"
    "To: joe@user.org,\r\n"
    "\tvalentine@14th.february.org\r\n"
    "Cc: boss@example.com\r\n"
    "\n"
    "From: \"Mutz, Marc\" <mutz@kde.org>\r\n"
    "Subject: missing subject\r\n"
    "To: joe@user.org,\r\n"
    "\tvalentine@14th.february.org\r\n"
    "Cc: boss@example.com\r\n"
    "\n"
    "From: =?utf-8?b?TWFyYyBNw7Z0eg==?= <mutz@kde.org>\r\n"
    "Subject: missing subject\r\n"
    "To: joe@user.org,\r\n"
    "\tvalentine@14th.february.org\r\n"
    "Cc: boss@example.com\r\n"
    "\n"
    "From: mutz@kde.org\r\n"
    "Subject: =?utf-8?b?QmzDtmRlcyBTdWJqZWN0?=\r\n"
    "To: joe@user.org,\r\n"
    "\tvalentine@14th.february.org\r\n"
    "Cc: boss@example.com\r\n"
    "\n"
    "From: Marc Mutz <mutz@kde.org>\r\n"
    "Subject: =?utf-8?b?QmzDtmRlcyBTdWJqZWN0?=\r\n"
    "To: joe@user.org,\r\n"
    "\tvalentine@14th.february.org\r\n"
    "Cc: boss@example.com\r\n"
    "\n"
    "From: \"Mutz, Marc\" <mutz@kde.org>\r\n"
    "Subject: =?utf-8?b?QmzDtmRlcyBTdWJqZWN0?=\r\n"
    "To: joe@user.org,\r\n"
    "\tvalentine@14th.february.org\r\n"
    "Cc: boss@example.com\r\n"
    "\n"
    "From: =?utf-8?b?TWFyYyBNw7Z0eg==?= <mutz@kde.org>\r\n"
    "Subject: =?utf-8?b?QmzDtmRlcyBTdWJqZWN0?=\r\n"
    "To: joe@user.org,\r\n"
    "\tvalentine@14th.february.org\r\n"
    "Cc: boss@example.com\r\n"
    "\n";

  KioSMTP::Request request;
  TQCString result;

  request.setEmitHeaders( true );
  request.setFromAddress( "mutz@kde.org" );
  request.addTo( "joe@user.org" );
  request.addTo( "valentine@14th.february.org" );
  request.addCc( "boss@example.com" );

  result += request.headerFields() + '\n';
  result += request.headerFields( "Marc Mutz" ) + '\n';
  result += request.headerFields( "Mutz, Marc" ) + '\n';
  result += request.headerFields( "Marc Mötz" ) + '\n';

  request.setSubject( "Blödes Subject" );

  result += request.headerFields() + '\n';
  result += request.headerFields( "Marc Mutz" ) + '\n';
  result += request.headerFields( "Mutz, Marc" ) + '\n';
  result += request.headerFields( "Marc Mötz" ) + '\n';

  //cout << "Result:\n" << result.data() << endl;

  return result == expected ? 0 : 1 ;
}

#include "request.cc"