mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-24 10:52:53 +00:00
103 lines
3.5 KiB
C++
103 lines
3.5 KiB
C++
/*
|
|
* This file is part of the syndication library
|
|
*
|
|
* Copyright (C) 2006 Frank Osterfeld <osterfeld@kde.org>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* 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.
|
|
*
|
|
*/
|
|
|
|
#include "testpersonimpl.h"
|
|
#include "person.h"
|
|
#include "personimpl.h"
|
|
#include "tools.h"
|
|
#include <QtCore/QList>
|
|
#include <QtCore/QString>
|
|
#include <QtCore/QStringList>
|
|
|
|
using Syndication::Person;
|
|
using Syndication::PersonPtr;
|
|
using Syndication::PersonImpl;
|
|
|
|
void TestPersonImpl::fromString()
|
|
{
|
|
QStringList s;
|
|
QList<PersonPtr> p;
|
|
|
|
|
|
|
|
s.append(QString());
|
|
p.append(PersonPtr(new PersonImpl(QString(), QString(), QString())));
|
|
|
|
s.append("");
|
|
p.append(PersonPtr(new PersonImpl(QString(), QString(), QString())));
|
|
|
|
s.append("foo@bar.com");
|
|
p.append(PersonPtr(new PersonImpl(QString(), QString(), "foo@bar.com")));
|
|
|
|
s.append("<foo@bar.com>");
|
|
p.append(PersonPtr(new PersonImpl(QString(), QString(), "foo@bar.com")));
|
|
|
|
s.append("Foo");
|
|
p.append(PersonPtr(new PersonImpl("Foo", QString(), QString())));
|
|
|
|
s.append("Foo M. Bar");
|
|
p.append(PersonPtr(new PersonImpl("Foo M. Bar", QString(), QString())));
|
|
|
|
s.append("Foo <foo@bar.com>");
|
|
p.append(PersonPtr(new PersonImpl("Foo", QString(), "foo@bar.com")));
|
|
|
|
s.append("Foo Bar <foo@bar.com>");
|
|
p.append(PersonPtr(new PersonImpl("Foo Bar", QString(), "foo@bar.com")));
|
|
|
|
s.append("John Doe (President) <john@doe.com>");
|
|
p.append(PersonPtr(new PersonImpl("John Doe (President)", QString(), "john@doe.com")));
|
|
|
|
s.append("John Doe (President)");
|
|
p.append(PersonPtr(new PersonImpl("John Doe (President)", QString(), QString() )));
|
|
|
|
s.append("John Doe (President)) <john@doe.com>");
|
|
p.append(PersonPtr(new PersonImpl("John Doe (President))", QString(), "john@doe.com")));
|
|
|
|
s.append("(President) John Doe <john@doe.com>");
|
|
p.append(PersonPtr(new PersonImpl("(President) John Doe", QString(), "john@doe.com")));
|
|
|
|
s.append("<foo@bar.com> (Foo Bar)");
|
|
p.append(PersonPtr(new PersonImpl("Foo Bar", QString(), "foo@bar.com")));
|
|
|
|
// s.append("OnAhlmann(mailto:&#111;&#110;&#97;&#104;&#108;&#109;&#97;&#110;&#110;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;)");
|
|
// p.append(PersonPtr(new PersonImpl("OnAhlmann", QString(), "onahlmann@gmail.com")));
|
|
|
|
QList<PersonPtr> q;
|
|
|
|
QStringList::ConstIterator it = s.constBegin();
|
|
QStringList::ConstIterator end = s.constEnd();
|
|
QList<PersonPtr>::ConstIterator pit = p.constBegin();
|
|
|
|
while (it != end)
|
|
{
|
|
PersonPtr q(Syndication::personFromString(*it));
|
|
QCOMPARE(q->name(), (*pit)->name());
|
|
QCOMPARE(q->email(), (*pit)->email());
|
|
QCOMPARE(q->uri(), (*pit)->uri());
|
|
|
|
++it;
|
|
++pit;
|
|
}
|
|
}
|
|
|
|
QTEST_MAIN(TestPersonImpl)
|
|
|