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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
|
/* This file is part of the KDE project
Copyright (C) 2004 David Faure <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
// Test program for libemailfunctions/email.h
#include "email.h"
#include <kcmdlineargs.h>
#include <kapplication.h>
#include <kdebug.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
using namespace KPIM;
static bool check(const TQString& txt, const TQString& a, const TQString& b)
{
if (a == b) {
kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "ok" << endl;
}
else {
kdDebug() << txt << " : checking '" << a << "' against expected value '" << b << "'... " << "KO !" << endl;
exit(1);
}
return true;
}
static bool check(const TQString& txt, const TQStringList& a, const TQStringList& b)
{
if ( a.join("\n") == b.join("\n") ) {
kdDebug() << txt << " : checking list [ " << a.join( ", " ) << " ] against expected value [ " << b.join( ", " ) << " ]... " << "ok" << endl;
}
else {
kdDebug() << txt << " : checking list [ " << a.join( ",\n" ) << " ] against expected value [ " << b.join( ",\n" ) << " ]... " << "KO !" << endl;
exit(1);
}
return true;
}
static bool checkGetNameAndEmail(const TQString& input, const TQString& expName, const TQString& expEmail, bool expRetVal)
{
TQString name, email;
bool retVal = KPIM::getNameAndMail(input, name, email);
check( "getNameAndMail " + input + " retVal", retVal?TQString::tqfromLatin1( "true" ):TQString::tqfromLatin1( "false" ), expRetVal?TQString::tqfromLatin1( "true" ):TQString::tqfromLatin1( "false" ) );
check( "getNameAndMail " + input + " name", name, expName );
check( "getNameAndMail " + input + " email", email, expEmail );
return true;
}
// convert this to a switch instead but hey, nothing speedy in here is needed but still.. it would be nice
static TQString emailTestParseResultToString( EmailParseResult errorCode )
{
if( errorCode == TooManyAts ) {
return "TooManyAts";
} else if( errorCode == TooFewAts ) {
return "TooFewAts";
} else if( errorCode == AddressEmpty ) {
return "AddressEmpty";
} else if( errorCode == MissingLocalPart ) {
return "MissingLocalPart";
} else if( errorCode == MissingDomainPart ) {
return "MissingDomainPart";
} else if( errorCode == UnbalancedParens ) {
return "UnbalancedParens";
} else if( errorCode == AddressOk ) {
return "AddressOk";
} else if( errorCode == UnclosedAngleAddr ) {
return "UnclosedAngleAddr";
} else if( errorCode == UnexpectedEnd ) {
return "UnexpectedEnd";
} else if( errorCode == UnopenedAngleAddr ) {
return "UnopenedAngleAddr";
} else if( errorCode == DisallowedChar ) {
return "DisallowedChar";
} else if( errorCode == UnexpectedComma ) {
return "UnexpectedComma";
} else if( errorCode == UnbalancedQuote ) {
return "UnbalancedQuote";
} else if( errorCode == InvalidDisplayName ) {
return "InvalidDisplayName";
}
return "unknown error code";
}
static TQString simpleEmailTestParseResultToString( bool validEmail )
{
if ( validEmail ) {
return "true";
}
return "false";
}
static bool checkIsValidEmailAddress( const TQString& input, const TQString& expErrorCode )
{
EmailParseResult errorCode = KPIM::isValidEmailAddress( input );
TQString errorC = emailTestParseResultToString( errorCode );
check( "isValidEmailAddress " + input + " errorCode ", errorC , expErrorCode );
return true;
}
static bool checkIsValidSimpleEmailAddress( const TQString& input, const TQString& expResult )
{
bool validEmail = KPIM::isValidSimpleEmailAddress( input );
TQString result = simpleEmailTestParseResultToString( validEmail );
check( "isValidSimpleEmailAddress " + input + " result ", result, expResult );
return true;
}
static bool checkGetEmailAddress( const TQString& input, const TQString& expResult )
{
TQString emailAddress = KPIM::getEmailAddress( input );
TQString result = emailAddress;
check( "getEmailAddress " + input + " result ", result, expResult );
return true;
}
static bool checkSplitEmailAddrList( const TQString& input, const TQStringList& expResult )
{
TQStringList emailAddresses = KPIM::splitEmailAddrList( input );
check( "splitEmailAddrList( \"" + input + "\" ) result ", emailAddresses, expResult );
return true;
}
static bool checkNormalizeAddressesAndEncodeIDNs( const TQString& input, const TQString& expResult )
{
TQString result = KPIM::normalizeAddressesAndEncodeIDNs( input );
check( "normalizeAddressesAndEncodeIDNs( \"" + input + "\" ) result ", result, expResult );
return true;
}
static bool checkNormalizeAddressesAndDecodeIDNs( const TQString& input, const TQString& expResult )
{
TQString result = KPIM::normalizeAddressesAndDecodeIDNs( input );
check( "normalizeAddressesAndDecodeIDNs( \"" + input + "\" ) result ", result, expResult );
return true;
}
static bool checkQuoteIfNecessary( const TQString& input, const TQString& expResult )
{
TQString result = quoteNameIfNecessary( input );
check( "quoteNameIfNecessary " + input + " result ", result, expResult );
return true;
}
int main(int argc, char *argv[])
{
KApplication::disableAutoDcopRegistration();
KCmdLineArgs::init( argc, argv, "testemail", 0, 0, 0, 0 );
KApplication app( false, false );
// Empty input
checkGetNameAndEmail( TQString(), TQString(), TQString(), false );
// Email only
checkGetNameAndEmail( "[email protected]", TQString(), "[email protected]", false );
// Normal case
checkGetNameAndEmail( "David Faure <[email protected]>", "David Faure", "[email protected]", true );
// Double-quotes
checkGetNameAndEmail( "\"Faure, David\" <[email protected]>", "Faure, David", "[email protected]", true );
checkGetNameAndEmail( "<[email protected]> \"David Faure\"", "David Faure", "[email protected]", true );
// Parenthesis
checkGetNameAndEmail( "[email protected] (David Faure)", "David Faure", "[email protected]", true );
checkGetNameAndEmail( "(David Faure) [email protected]", "David Faure", "[email protected]", true );
checkGetNameAndEmail( "My Name (me) <[email protected]>", "My Name (me)", "[email protected]", true ); // #93513
// Nested parenthesis as per https://intevation.de/roundup/kolab/issue858
checkGetNameAndEmail( "[email protected] (David (The Man) Faure)", "David (The Man) Faure", "[email protected]", true );
// Double-quotes inside parenthesis
checkGetNameAndEmail( "[email protected] (David \"Crazy\" Faure)", "David \"Crazy\" Faure", "[email protected]", true );
checkGetNameAndEmail( "(David \"Crazy\" Faure) [email protected]", "David \"Crazy\" Faure", "[email protected]", true );
// Parenthesis inside double-quotes
checkGetNameAndEmail( "\"Faure (David)\" <[email protected]>", "Faure (David)", "[email protected]", true );
checkGetNameAndEmail( "<[email protected]> \"Faure (David)\"", "Faure (David)", "[email protected]", true );
// Space in email
checkGetNameAndEmail( "David Faure < [email protected] >", "David Faure", "[email protected]", true );
// Check that '@' in name doesn't confuse it
checkGetNameAndEmail( "[email protected] (a@b)", "a@b", "[email protected]", true );
// Interestingly, this isn't supported.
//checkGetNameAndEmail( "\"a@b\" <[email protected]>", "a@b", "[email protected]", true );
// While typing, when there's no '@' yet
checkGetNameAndEmail( "foo", "foo", TQString(), false );
checkGetNameAndEmail( "foo <", "foo", TQString(), false );
checkGetNameAndEmail( "foo <b", "foo", "b", true );
// If multiple emails are there, only return the first one
checkGetNameAndEmail( "\"Faure, David\" <[email protected]>, KHZ <[email protected]>", "Faure, David", "[email protected]", true );
// domain literals also need to work
checkGetNameAndEmail( "Matt Douhan <matt@[123.123.123.123]>", "Matt Douhan", "matt@[123.123.123.123]", true );
// @ inside the comment
checkGetNameAndEmail( "\"Matt@Douhan\" <[email protected]>", "Matt@Douhan", "[email protected]", true );
// No '@'
checkGetNameAndEmail( "foo <distlist>", "foo", "distlist", true );
// To many @'s
checkIsValidEmailAddress( "matt@@fruitsalad.org", "TooManyAts" );
// To few @'s
checkIsValidEmailAddress( "mattfruitsalad.org", "TooFewAts" );
// An empty string
checkIsValidEmailAddress( TQString() , "AddressEmpty" );
// email address starting with a @
checkIsValidEmailAddress( "@mattfruitsalad.org", "MissingLocalPart" );
// make sure that starting @ and an additional @ in the same email address don't conflict
// trap the starting @ first and break
checkIsValidEmailAddress( "@[email protected]", "MissingLocalPart" );
// email address ending with a @
checkIsValidEmailAddress( "mattfruitsalad.org@", "MissingDomainPart" );
// make sure that ending with@ and an additional @ in the email address don't conflict
checkIsValidEmailAddress( "[email protected]@", "MissingDomainPart" );
// unbalanced Parens
checkIsValidEmailAddress( "mattjongel)@fruitsalad.org", "UnbalancedParens" );
// unbalanced Parens the other way around
checkIsValidEmailAddress( "mattjongel(@fruitsalad.org", "UnbalancedParens" );
// Correct parens just to make sure it works
checkIsValidEmailAddress( "matt(jongel)@fruitsalad.org", "AddressOk" );
// Check that anglebrackets are closed
checkIsValidEmailAddress( "matt douhan<[email protected]", "UnclosedAngleAddr" );
// Check that angle brackets are closed the other way around
checkIsValidEmailAddress( "matt douhan>[email protected]", "UnopenedAngleAddr" );
// Check that angle brackets are closed the other way around, and anglebrackets in domainpart
// instead of local part
checkIsValidEmailAddress( "matt douhan matt@<fruitsalad.org", "UnclosedAngleAddr" );
// check that a properly formated anglebrackets situation is OK
checkIsValidEmailAddress( "matt douhan<[email protected]>", "AddressOk" );
// a full email address with comments angle brackets and the works should be valid too
checkIsValidEmailAddress( "Matt (jongel) Douhan <[email protected]>", "AddressOk" );
// Double quotes
checkIsValidEmailAddress( "\"Matt Douhan\" <[email protected]>", "AddressOk" );
// Double quotes inside parens
checkIsValidEmailAddress( "Matt (\"jongel\") Douhan <[email protected]>", "AddressOk" );
// DOuble quotes not closed
checkIsValidEmailAddress( "Matt \"jongel Douhan <[email protected]>", "UnbalancedQuote" );
// Parens inside double quotes
checkIsValidEmailAddress( "Matt \"(jongel)\" Douhan <[email protected]>", "AddressOk" );
// Space in email
checkIsValidEmailAddress( "Matt Douhan < [email protected] >", "AddressOk" );
// @ is allowed inisde doublequotes
checkIsValidEmailAddress( "\"matt@jongel\" <[email protected]>", "AddressOk" );
// anglebrackets inside dbl quotes
checkIsValidEmailAddress( "\"matt<blah blah>\" <[email protected]>", "AddressOk" );
// a , inside a double quoted string is OK, how do I know this? well Ingo says so
// and it makes sense since it is also a seperator of email addresses
checkIsValidEmailAddress( "\"Douhan, Matt\" <[email protected]>", "AddressOk" );
// Domains literals also need to work
checkIsValidEmailAddress( "Matt Douhan <matt@[123.123.123.123]>", "AddressOk" );
// Typo in domain literal address
checkIsValidEmailAddress( "Matt Douhan <matt@[123.123.123,123]>", "UnexpectedComma" );
// Some more insane tests but still valid so they must work
checkIsValidEmailAddress( "Matt Douhan <\"m@att\"@jongel.com>", "AddressOk" );
// BUG 99657
checkIsValidEmailAddress( "[email protected]", "AddressOk" );
// BUG 98720
checkIsValidEmailAddress( "mailto:@mydomain", "DisallowedChar" );
// correct error msg when a comma is inside <>
checkIsValidEmailAddress( "Matt Douhan <matt@fruitsalad,org>", "UnexpectedComma" );
//several commentlevels
checkIsValidEmailAddress( "Matt Douhan (hey(jongel)fibbel) <[email protected]>", "AddressOk" );
// several comment levels and one (the outer) being unbalanced
checkIsValidEmailAddress( "Matt Douhan (hey(jongel)fibbel <[email protected]>", "UnbalancedParens" );
// several comment levels and one (the inner) being unbalanced
checkIsValidEmailAddress( "Matt Douhan (hey(jongelfibbel) <[email protected]>", "UnbalancedParens" );
// an error inside a double quote is no error
checkIsValidEmailAddress ( "Matt Douhan \"(jongel\" <[email protected]>", "AddressOk" );
// inside a quoted string double quotes are only allowed in pairs as per rfc2822
checkIsValidEmailAddress( "Matt Douhan \"jongel\"fibbel\" <[email protected]>", "UnbalancedQuote" );
// a questionmark is valid in an atom
checkIsValidEmailAddress ( "Matt? <[email protected]>", "AddressOk" );
// weird but OK
checkIsValidEmailAddress( "\"testing, \\\"testing\" <[email protected]>", "AddressOk" );
// escape a quote to many to see if it makes it invalid
checkIsValidEmailAddress( "\"testing, \\\"testing\\\" <[email protected]>", "UnbalancedQuote" );
// escape a parens and thus make a comma appear
checkIsValidEmailAddress( "Matt (jongel, fibbel\\) <[email protected]>", "UnbalancedParens" );
// several errors inside doublequotes
checkIsValidEmailAddress( "Matt \"(jongel,\\\" < fibbel\\\\)\" <[email protected]>", "AddressOk" );
// BUG 105705
checkIsValidEmailAddress( "[email protected]", "AddressOk" );
// underscore at the end of local part
checkIsValidEmailAddress( "[email protected]", "AddressOk" );
// how about ( comment ) in the domain part
checkIsValidEmailAddress( "matt_@(this is a cool host)fruitsalad.org", "AddressOk" );
// To quote rfc2822 the test below is aesthetically displeasing, but perfectly legal.
checkIsValidEmailAddress( "Pete(A wonderful \\) chap) <pete(his account)@silly.test(his host)>", "AddressOk" );
// quoted pair or not quoted pair
checkIsValidEmailAddress( "\"jongel '\\\" fibbel\" <[email protected]>", "AddressOk" );
checkIsValidEmailAddress( "\"jongel '\" fibbel\" <[email protected]>", "UnbalancedQuote" );
// full atext support according to rfc2822
checkIsValidEmailAddress( "[email protected]", "AddressOk" );
checkIsValidEmailAddress( "#[email protected]", "AddressOk" );
checkIsValidEmailAddress( "[email protected]", "AddressOk" );
checkIsValidEmailAddress( "%[email protected]", "AddressOk" );
checkIsValidEmailAddress( "&[email protected]", "AddressOk" );
checkIsValidEmailAddress( "'[email protected]", "AddressOk" );
checkIsValidEmailAddress( "*[email protected]", "AddressOk" );
checkIsValidEmailAddress( "[email protected]", "AddressOk" );
checkIsValidEmailAddress( "/[email protected]", "AddressOk" );
checkIsValidEmailAddress( "[email protected]", "AddressOk" );
checkIsValidEmailAddress( "[email protected]", "AddressOk" );
checkIsValidEmailAddress( "^[email protected]", "AddressOk" );
checkIsValidEmailAddress( "[email protected]", "AddressOk" );
checkIsValidEmailAddress( "[email protected]", "AddressOk" );
checkIsValidEmailAddress( "`[email protected]", "AddressOk" );
checkIsValidEmailAddress( "{[email protected]", "AddressOk" );
checkIsValidEmailAddress( "|[email protected]", "AddressOk" );
checkIsValidEmailAddress( "}[email protected]", "AddressOk" );
checkIsValidEmailAddress( "[email protected]", "AddressOk" );
checkIsValidEmailAddress( "matt%[email protected]", "AddressOk" );
//bug 105405
checkIsValidEmailAddress( "[foobar] <[email protected]>", "InvalidDisplayName" );
checkIsValidEmailAddress( "matt \"[foobar]\" Douhan <[email protected]>", "AddressOk" );
checkIsValidEmailAddress( "Matt Douhan <matt\"@@\"fruitsalad.org>", "TooFewAts" );
// checks for "pure" email addresses in the form of [email protected]
checkIsValidSimpleEmailAddress( "[email protected]", "true" );
checkIsValidSimpleEmailAddress( TQString::fromUtf8("test@täst.invalid"), "true" );
// non-ASCII char as first char of IDN
checkIsValidSimpleEmailAddress( TQString::fromUtf8("i_want@øl.invalid"), "true" );
checkIsValidSimpleEmailAddress( "matt@[123.123.123.123]", "true" );
checkIsValidSimpleEmailAddress( "matt@[3.3.3.3]", "true" );
checkIsValidSimpleEmailAddress( "matt@[4.4.4.4]", "true" );
checkIsValidSimpleEmailAddress( "matt@[192.168.254.254]", "true" );
checkIsValidSimpleEmailAddress( "\"matt\"@fruitsalad.org", "true" );
checkIsValidSimpleEmailAddress( "[email protected]", "true" );
checkIsValidSimpleEmailAddress( "\"-matt\"@fruitsalad.org", "true" );
checkIsValidSimpleEmailAddress( "[email protected]", "true" );
checkIsValidSimpleEmailAddress( "Matt Douhan <[email protected]>", "false" );
// BUG 105705
checkIsValidSimpleEmailAddress( "[email protected]", "true" );
checkIsValidSimpleEmailAddress( "[email protected]", "true" );
checkIsValidSimpleEmailAddress( "[email protected]", "true" );
// Check the defined chars for atext according to rfc2822
checkIsValidSimpleEmailAddress( "[email protected]", "true" );
checkIsValidSimpleEmailAddress( "#[email protected]", "true" );
checkIsValidSimpleEmailAddress( "[email protected]", "true" );
checkIsValidSimpleEmailAddress( "%[email protected]", "true" );
checkIsValidSimpleEmailAddress( "&[email protected]", "true" );
checkIsValidSimpleEmailAddress( "'[email protected]", "true" );
checkIsValidSimpleEmailAddress( "*[email protected]", "true" );
checkIsValidSimpleEmailAddress( "[email protected]", "true" );
checkIsValidSimpleEmailAddress( "/[email protected]", "true" );
checkIsValidSimpleEmailAddress( "[email protected]", "true" );
checkIsValidSimpleEmailAddress( "[email protected]", "true" );
checkIsValidSimpleEmailAddress( "^[email protected]", "true" );
checkIsValidSimpleEmailAddress( "[email protected]", "true" );
checkIsValidSimpleEmailAddress( "[email protected]", "true" );
checkIsValidSimpleEmailAddress( "`[email protected]", "true" );
checkIsValidSimpleEmailAddress( "{[email protected]", "true" );
checkIsValidSimpleEmailAddress( "|[email protected]", "true" );
checkIsValidSimpleEmailAddress( "}[email protected]", "true" );
checkIsValidSimpleEmailAddress( "[email protected]", "true" );
// BUG 108476
checkIsValidSimpleEmailAddress( "[email protected]", "true" );
checkIsValidSimpleEmailAddress( "[email protected]", "true" );
checkIsValidSimpleEmailAddress( "[email protected]", "true" );
checkIsValidSimpleEmailAddress( "[email protected]", "true" );
// check if the pure email address is wrong
checkIsValidSimpleEmailAddress( "mattfruitsalad.org", "false" );
checkIsValidSimpleEmailAddress( "matt@[123.123.123.123", "false" );
checkIsValidSimpleEmailAddress( "[email protected]]", "false" );
checkIsValidSimpleEmailAddress( "\"[email protected]", "false" );
checkIsValidSimpleEmailAddress( "matt\"@fruitsalad.org", "false" );
checkIsValidSimpleEmailAddress( TQString(), "false" );
// and here some insane but still valid cases
checkIsValidSimpleEmailAddress( "\"m@tt\"@fruitsalad.org", "true" );
checkIsValidSimpleEmailAddress( "matt\"@@\"fruitsalad.org", "false" );
// check the getEmailAddress address method
checkGetEmailAddress( "[email protected]", "[email protected]" );
checkGetEmailAddress( "Matt Douhan <[email protected]>", "[email protected]" );
checkGetEmailAddress( "\"Matt Douhan <blah blah>\" <[email protected]>", "[email protected]" );
checkGetEmailAddress( "\"Matt <blah blah>\" <[email protected]>", "[email protected]" );
checkGetEmailAddress( "Matt Douhan (jongel) <[email protected]", TQString() );
checkGetEmailAddress( "Matt Douhan (m@tt) <[email protected]>", "[email protected]" );
checkGetEmailAddress( "\"Douhan, Matt\" <[email protected]>", "[email protected]" );
checkGetEmailAddress( "\"Matt Douhan (m@tt)\" <[email protected]>", "[email protected]" );
checkGetEmailAddress( "\"Matt Douhan\" (matt <[email protected]>", TQString() );
checkGetEmailAddress( "Matt Douhan <matt@[123.123.123.123]>", "matt@[123.123.123.123]" );
// check the splitEmailAddrList method
checkSplitEmailAddrList( "[email protected] (Kloecker, Ingo)", TQStringList() << "[email protected] (Kloecker, Ingo)" );
checkSplitEmailAddrList( "Matt Douhan <[email protected]>, Foo Bar <[email protected]>", TQStringList() << "Matt Douhan <[email protected]>" << "Foo Bar <[email protected]>" );
checkSplitEmailAddrList( "\"Matt, Douhan\" <[email protected]>, Foo Bar <[email protected]>", TQStringList() << "\"Matt, Douhan\" <[email protected]>" << "Foo Bar <[email protected]>" );
// check checkNormalizeAddressesAndEncodeIDNs
checkNormalizeAddressesAndEncodeIDNs( "[email protected]", "[email protected]" );
checkNormalizeAddressesAndEncodeIDNs( "Matt Douhan <[email protected]>", "Matt Douhan <[email protected]>" );
checkNormalizeAddressesAndEncodeIDNs( "Matt Douhan (jongel) <[email protected]>", "Matt Douhan (jongel) <[email protected]>" );
checkNormalizeAddressesAndEncodeIDNs( "Matt Douhan (jongel,fibbel) <[email protected]>", "Matt Douhan (jongel,fibbel) <[email protected]>" );
checkNormalizeAddressesAndEncodeIDNs( "[email protected] (jongel,fibbel)", "\"jongel,fibbel\" <[email protected]>" );
checkNormalizeAddressesAndEncodeIDNs( "[email protected] (\"jongel,fibbel\")", "\"jongel,fibbel\" <[email protected]>" );
// check checkNormalizeAddressesAndDecodeIDNs
checkNormalizeAddressesAndDecodeIDNs( "=?us-ascii?Q?Surname=2C=20Name?= <[email protected]>", "\"Surname, Name\" <[email protected]>" );
checkNormalizeAddressesAndDecodeIDNs( "=?iso-8859-1?B?5Hf8b2xmLPZBbmRyZWFz?= <[email protected]>", TQString::fromUtf8("\"äwüolf,öAndreas\" <[email protected]>") );
// check the "quote if necessary" method
checkQuoteIfNecessary( "Matt Douhan", "Matt Douhan");
checkQuoteIfNecessary( "Douhan, Matt", "\"Douhan, Matt\"");
checkQuoteIfNecessary( "Matt \"jongel\" Douhan", "\"Matt \\\"jongel\\\" Douhan\"");
checkQuoteIfNecessary( "Matt \\\"jongel\\\" Douhan", "\"Matt \\\"jongel\\\" Douhan\"");
checkQuoteIfNecessary( "trailing '\\\\' should never occur \\", "\"trailing '\\\\' should never occur \\\"");
checkQuoteIfNecessary( "\"don't quote again\"", "\"don't quote again\"" );
checkQuoteIfNecessary( "\"leading double quote", "\"\\\"leading double quote\"" );
checkQuoteIfNecessary( "trailing double quote\"", "\"trailing double quote\\\"\"" );
printf("\nTest OK !\n");
return 0;
}
|