add: 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\\\"\"" );
context: int main(int argc, char *argv[]){  KApplication::disableAutoDcopRegistration();  KCmdLineArgs::init( argc, argv, "testemail", 0, 0, 0, 0 );  KApplication app( false, false );  // Empty input  checkGetNameAndEmail( QString::null, QString::null, QString::null, false );  // Email only  checkGetNameAndEmail( "faure@kde.org", QString::null, "faure@kde.org", false );  // Normal case  checkGetNameAndEmail( "David Faure <faure@kde.org>", "David Faure", "faure@kde.org", true );  // Double-quotes  checkGetNameAndEmail( "\"Faure, David\" <faure@kde.org>", "Faure, David", "faure@kde.org", true );  checkGetNameAndEmail( "<faure@kde.org> \"David Faure\"", "David Faure", "faure@kde.org", true );  // Parenthesis  checkGetNameAndEmail( "faure@kde.org (David Faure)", "David Faure", "faure@kde.org", true );  checkGetNameAndEmail( "(David Faure) faure@kde.org", "David Faure", "faure@kde.org", true );  checkGetNameAndEmail( "My Name (me) <me@home.net>", "My Name (me)", "me@home.net", true ); // #93513  // Double-quotes inside parenthesis  checkGetNameAndEmail( "faure@kde.org (David \"Crazy\" Faure)", "David \"Crazy\" Faure", "faure@kde.org", true );  checkGetNameAndEmail( "(David \"Crazy\" Faure) faure@kde.org", "David \"Crazy\" Faure", "faure@kde.org", true );  // Parenthesis inside double-quotes  checkGetNameAndEmail( "\"Faure (David)\" <faure@kde.org>", "Faure (David)", "faure@kde.org", true );  checkGetNameAndEmail( "<faure@kde.org> \"Faure (David)\"", "Faure (David)", "faure@kde.org", true );  // Space in email  checkGetNameAndEmail( "David Faure < faure@kde.org >", "David Faure", "faure@kde.org", true );  // Check that '@' in name doesn't confuse it  checkGetNameAndEmail( "faure@kde.org (a@b)", "a@b", "faure@kde.org", true );  // Interestingly, this isn't supported.  //checkGetNameAndEmail( "\"a@b\" <faure@kde.org>", "a@b", "faure@kde.org", true );  // While typing, when there's no '@' yet  checkGetNameAndEmail( "foo", "foo", QString::null, false );  checkGetNameAndEmail( "foo <", "foo", QString::null, false );  checkGetNameAndEmail( "foo <b", "foo", "b", true );  // If multiple emails are there, only return the first one  checkGetNameAndEmail( "\"Faure, David\" <faure@kde.org>, KHZ <khz@khz.khz>", "Faure, David", "faure@kde.org", true );  // domain literals also need to work  checkGetNameAndEmail( "Matt Douhan <matt@[123.123.123.123]>", "Matt Douhan", "matt@[123.123.123.123]", 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( QString::null , "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( "@matt@fruitsalad.org", "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( "matt@fruitsalad.org@", "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<matt@fruitsalad.org", "UnclosedAngleAddr" );  // Check that angle brackets are closed the other way around  checkIsValidEmailAddress( "matt douhan>matt@fruitsalad.org", "UnopenedAngleAddr" );  // Check that angle brackets are closed the other way around, and anglebrackets in domainpart  // instead of local part  // checkIsValidEmailAddress( "matt douhanmatt@<fruitsalad.org", "UnclosedAngleAddr" );   // check that a properly formated anglebrackets situation is OK  checkIsValidEmailAddress( "matt douhan<matt@fruitsalad.org>", "AddressOk" );  // a full email address with comments angle brackets and the works should be valid too  checkIsValidEmailAddress( "Matt (jongel) Douhan <matt@fruitsalad.org>", "AddressOk" );  // Double quotes          checkIsValidEmailAddress( "\"Matt Douhan\" <matt@fruitsalad.org>", "AddressOk" );  // Double quotes inside parens  checkIsValidEmailAddress( "Matt (\"jongel\") Douhan <matt@fruitsalad.org>", "AddressOk" );  // Parens inside double quotes  checkIsValidEmailAddress( "Matt \"(jongel)\" Douhan <matt@fruitsalad.org>", "AddressOk" );  // Space in email  checkIsValidEmailAddress( "Matt Douhan < matt@fruitsalad.org >", "AddressOk" );  // @ is allowed inisde doublequotes  checkIsValidEmailAddress( "\"matt@jongel\" <matt@fruitsalad.org>", "AddressOk" );  // anglebrackets inside dbl quotes   checkIsValidEmailAddress( "\"matt<blah blah>\" <matt@fruitsalad.org>", "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\" <matt@fruitsalad.org>", "AddressOk" );  // Domains literals also need to work  checkIsValidEmailAddress( "Matt Douhan <matt@[123.123.123.123]>", "AddressOk" );  // Some more insane tests but still valid so they must work  checkIsValidEmailAddress( "Matt Douhan <\"m@att\"@jongel.com>", "AddressOk" );  // BUG 99657  checkIsValidEmailAddress( "matt@jongel.fibbel.com", "AddressOk" );  // checks for "pure" email addresses in the form of xxx@yyy.tld  checkIsValidSimpleEmailAddress( "matt@fruitsalad.org", "true" );  checkIsValidSimpleEmailAddress( QString::fromUtf8("test@täst.invalid"), "true" );  // non-ASCII char as first char of IDN  checkIsValidSimpleEmailAddress( QString::fromUtf8("i_want@øl.invalid"), "true" );  checkIsValidSimpleEmailAddress( "matt@[123.123.123.123]", "true" );  checkIsValidSimpleEmailAddress( "\"matt\"@fruitsalad.org", "true" );  checkIsValidSimpleEmailAddress( "-matt@fruitsalad.org", "true" );  checkIsValidSimpleEmailAddress( "\"-matt\"@fruitsalad.org", "true" );  checkIsValidSimpleEmailAddress( "matt@jongel.fibbel.com", "true" );  checkIsValidSimpleEmailAddress( "Matt Douhan <matt@fruitsalad.org>", "false" );  // check if the pure email address is wrong  checkIsValidSimpleEmailAddress( "mattfruitsalad.org", "false" );  checkIsValidSimpleEmailAddress( "matt@[123.123.123.123", "false" );  checkIsValidSimpleEmailAddress( "matt@123.123.123.123]", "false" );  checkIsValidSimpleEmailAddress( "\"matt@fruitsalad.org", "false" );  checkIsValidSimpleEmailAddress( "matt\"@fruitsalad.org", "false" );  checkIsValidSimpleEmailAddress( QString::null, "false" );  // and here some insane but still valid cases  checkIsValidSimpleEmailAddress( "\"m@tt\"@fruitsalad.org", "true" );  // check the getEmailAddress address method  checkGetEmailAddress( "matt@fruitsalad.org", "matt@fruitsalad.org" );  checkGetEmailAddress( "Matt Douhan <matt@fruitsalad.org>", "matt@fruitsalad.org" );  checkGetEmailAddress( "\"Matt Douhan <blah blah>\" <matt@fruitsalad.org>", "matt@fruitsalad.org" );   checkGetEmailAddress( "\"Matt <blah blah>\" <matt@fruitsalad.org>", "matt@fruitsalad.org" );   checkGetEmailAddress( "Matt Douhan (jongel) <matt@fruitsalad.org", QString() );  checkGetEmailAddress( "Matt Douhan (m@tt) <matt@fruitsalad.org>", "matt@fruitsalad.org" );  checkGetEmailAddress( "\"Douhan, Matt\" <matt@fruitsalad.org>", "matt@fruitsalad.org" );  checkGetEmailAddress( "\"Matt Douhan (m@tt)\" <matt@fruitsalad.org>", "matt@fruitsalad.org" );  checkGetEmailAddress( "\"Matt Douhan\" (matt <matt@fruitsalad.org>", QString() );  checkGetEmailAddress( "Matt Douhan <matt@[123.123.123.123]>", "matt@[123.123.123.123]" );   // check the splitEmailAddrList method  checkSplitEmailAddrList( "Matt Douhan <matt@fruitsalad.org>, Foo Bar <foo@bar.com>", "Matt Douhan <matt@fruitsalad.org>,Foo Bar <foo@bar.com>" );  checkSplitEmailAddrList( "\"Matt, Douhan\" <matt@fruitsalad.org>, Foo Bar <foo@bar.com>", "\"Matt, Douhan\" <matt@fruitsalad.org>,Foo Bar <foo@bar.com>" );  printf("\nTest OK !\n");  return 0;}