summaryrefslogtreecommitdiffstats
path: root/tdeioslave/smtp/test_headergeneration.cpp
blob: 9e4cb971f35a9549e4fd0accabf668f088379ac6 (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: [email protected]\r\n"
    "Subject: missing subject\r\n"
    "To: [email protected],\r\n"
    "\[email protected]\r\n"
    "Cc: [email protected]\r\n"
    "\n"
    "From: Marc Mutz <[email protected]>\r\n"
    "Subject: missing subject\r\n"
    "To: [email protected],\r\n"
    "\[email protected]\r\n"
    "Cc: [email protected]\r\n"
    "\n"
    "From: \"Mutz, Marc\" <[email protected]>\r\n"
    "Subject: missing subject\r\n"
    "To: [email protected],\r\n"
    "\[email protected]\r\n"
    "Cc: [email protected]\r\n"
    "\n"
    "From: =?utf-8?b?TWFyYyBNw7Z0eg==?= <[email protected]>\r\n"
    "Subject: missing subject\r\n"
    "To: [email protected],\r\n"
    "\[email protected]\r\n"
    "Cc: [email protected]\r\n"
    "\n"
    "From: [email protected]\r\n"
    "Subject: =?utf-8?b?QmzDtmRlcyBTdWJqZWN0?=\r\n"
    "To: [email protected],\r\n"
    "\[email protected]\r\n"
    "Cc: [email protected]\r\n"
    "\n"
    "From: Marc Mutz <[email protected]>\r\n"
    "Subject: =?utf-8?b?QmzDtmRlcyBTdWJqZWN0?=\r\n"
    "To: [email protected],\r\n"
    "\[email protected]\r\n"
    "Cc: [email protected]\r\n"
    "\n"
    "From: \"Mutz, Marc\" <[email protected]>\r\n"
    "Subject: =?utf-8?b?QmzDtmRlcyBTdWJqZWN0?=\r\n"
    "To: [email protected],\r\n"
    "\[email protected]\r\n"
    "Cc: [email protected]\r\n"
    "\n"
    "From: =?utf-8?b?TWFyYyBNw7Z0eg==?= <[email protected]>\r\n"
    "Subject: =?utf-8?b?QmzDtmRlcyBTdWJqZWN0?=\r\n"
    "To: [email protected],\r\n"
    "\[email protected]\r\n"
    "Cc: [email protected]\r\n"
    "\n";

  KioSMTP::Request request;
  TQCString result;

  request.setEmitHeaders( true );
  request.setFromAddress( "[email protected]" );
  request.addTo( "[email protected]" );
  request.addTo( "[email protected]" );
  request.addCc( "[email protected]" );

  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.cpp"