diff --git a/tests/testhelpers.h b/tests/testhelpers.h index f050ef3..fa7b149 100644 --- a/tests/testhelpers.h +++ b/tests/testhelpers.h @@ -1,324 +1,324 @@ /* * Copyright (C) 2012 Christian Mollekopf * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef TESTHELPERS_H #define TESTHELPERS_H #include #include #include #include #include #include #include #include #include Q_DECLARE_METATYPE(Kolab::Duration); Q_DECLARE_METATYPE(Kolab::cDateTime); Q_DECLARE_METATYPE(std::vector); Q_DECLARE_METATYPE(Kolab::Event); Q_DECLARE_METATYPE(std::vector); Q_DECLARE_METATYPE(Kolab::Todo); Q_DECLARE_METATYPE(Kolab::Journal); Q_DECLARE_METATYPE(Kolab::Contact); Q_DECLARE_METATYPE(Kolab::Period); Q_DECLARE_METATYPE(std::vector); Q_DECLARE_METATYPE(KCalCore::Event); Q_DECLARE_METATYPE(KCalCore::Todo); Q_DECLARE_METATYPE(KCalCore::Journal); namespace QTest { template<> char *toString(const Kolab::cDateTime &dt) { QByteArray ba = "Kolab::cDateTime("; ba += QByteArray::number(dt.year()) + ", " + QByteArray::number(dt.month())+ ", " + QByteArray::number(dt.day()) + ", "; ba += QByteArray::number(dt.hour()) + ", " + QByteArray::number(dt.minute()) + ", " + QByteArray::number(dt.second())+ ", "; - ba += QString(dt.isUTC()?QString("UTC"):QString("TZ: "+QString::fromStdString(dt.timezone()))).toAscii(); + ba += QByteArray(dt.isUTC()?QByteArray("UTC"):QByteArray("TZ: "+QByteArray::fromStdString(dt.timezone()))); ba += ")"; return qstrdup(ba.data()); } template<> char *toString(const KDateTime &dt) { QByteArray ba = "KDateTime("; ba += dt.toString().toAscii(); - ba += dt.timeZone().name(); + ba += dt.timeZone().name().toAscii(); ba += ")"; return qstrdup(ba.data()); } template<> char *toString(const KCalCore::Attendee &at) { QByteArray ba = "Attendee("; ba += at.name().toAscii() + ", "; ba += at.email().toAscii() + ", "; - ba += QString::number(at.role()) + ", "; - ba += QString::number(at.status()) + ", "; - ba += QString::number(at.RSVP()) + ", "; + ba += QByteArray::number(at.role()) + ", "; + ba += QByteArray::number(at.status()) + ", "; + ba += QByteArray::number(at.RSVP()) + ", "; ba += at.delegate().toAscii() + ", "; ba += at.delegator().toAscii() + ", "; ba += at.uid().toAscii() + ", "; ba += ")"; return qstrdup(ba.data()); } template<> char *toString(const QList &l) { QByteArray ba = "QList("; foreach(int i, l) { - ba += QString::number(i) + ", "; + ba += QByteArray::number(i) + ", "; } ba += ")"; return qstrdup(ba.data()); } template<> char *toString(const QList &l) { QByteArray ba = "QList("; foreach(const KCalCore::RecurrenceRule::WDayPos &i, l) { - ba += QString::number(i.pos()) + " "; - ba += QString::number(i.day()) + ", "; + ba += QByteArray::number(i.pos()) + " "; + ba += QByteArray::number(i.day()) + ", "; } ba += ")"; return qstrdup(ba.data()); } template<> char *toString(const KCalCore::DateList &l) { QByteArray ba = "KCalCore::DateList("; foreach(const QDate &i, l) { - ba += i.toString(); + ba += i.toString().toLatin1(); } ba += ")"; return qstrdup(ba.data()); } template<> char *toString(const KCalCore::DateTimeList &l) { QByteArray ba = "KCalCore::DateTimeList("; foreach(const KDateTime &i, l) { ba += toString(i); } ba += ")"; return qstrdup(ba.data()); } template<> char *toString(const KCalCore::Recurrence &at) { // at.dump(); KCalCore::RecurrenceRule *r = at.defaultRRule(); QByteArray ba; if (!r) { ba += "Recurrence( )"; } else { Q_ASSERT(r); Q_ASSERT(at.rRules().size() == 1); ba += "Recurrence("; - ba += QString::number(r->recurrenceType()) + "\n"; - ba += QString::number(r->frequency()) + "\n"; - ba += QString::number(r->duration()) + "\n"; + ba += QByteArray::number(r->recurrenceType()) + "\n"; + ba += QByteArray::number(r->frequency()) + "\n"; + ba += QByteArray::number(r->duration()) + "\n"; ba += QByteArray(toString(r->startDt())) + "\n"; ba += QByteArray(toString(r->endDt())) + "\n"; ba += QByteArray(toString(r->bySeconds())) + "\n"; ba += QByteArray(toString(r->byMinutes())) + "\n"; ba += QByteArray(toString(r->byHours())) + "\n"; ba += QByteArray(toString(r->byDays())) + "\n"; ba += QByteArray(toString(r->byMonthDays())) + "\n"; ba += QByteArray(toString(r->byYearDays())) + "\n"; ba += QByteArray(toString(r->byMonths())) + "\n"; ba += ")\n"; ba += QByteArray(toString(at.exDates())) + "\n"; ba += QByteArray(toString(at.exDateTimes())) + "\n"; ba += QByteArray(toString(at.rDates())) + "\n"; ba += QByteArray(toString(at.rDateTimes())) + "\n"; } return qstrdup(ba.data()); } template<> char *toString(const Kolab::RecurrenceRule &at) { QByteArray ba; ba += "KolabRecurrenceRule("; - ba += QString::number(at.weekStart()) + "\n"; - ba += QString::number(at.frequency()) + "\n"; - ba += QString::number(at.interval()) + "\n"; - ba += QString::number(at.count()) + "\n"; + ba += QByteArray::number(at.weekStart()) + "\n"; + ba += QByteArray::number(at.frequency()) + "\n"; + ba += QByteArray::number(at.interval()) + "\n"; + ba += QByteArray::number(at.count()) + "\n"; ba += QByteArray(toString(at.end())) + "\n"; ba += QByteArray(toString(at.bysecond())) + "\n"; ba += QByteArray(toString(at.byminute())) + "\n"; ba += QByteArray(toString(at.byhour())) + "\n"; ba += QByteArray(toString(at.byday())) + "\n"; ba += QByteArray(toString(at.bymonthday())) + "\n"; ba += QByteArray(toString(at.byyearday())) + "\n"; ba += QByteArray(toString(at.byweekno())) + "\n"; ba += QByteArray(toString(at.bymonth())) + "\n"; ba += ")"; return qstrdup(ba.data()); } template<> char *toString(const KCalCore::Duration &d) { QByteArray ba; ba += "KCalCore::Duration("; - ba += QString::number(d.isDaily()) + ", "; - ba += QString::number(d.value()) + " "; + ba += QByteArray::number(d.isDaily()) + ", "; + ba += QByteArray::number(d.value()) + " "; ba += ")"; return qstrdup(ba.data()); } template<> char *toString(const Kolab::ContactReference &a) { QByteArray ba = "Kolab::ContactReference("; - ba += QString::fromStdString(a.email()).toAscii()+ ", "; - ba += QString::fromStdString(a.name()).toAscii()+ ", "; - ba += QString::fromStdString(a.uid()).toAscii(); + ba += QByteArray::fromStdString(a.email()) + ", "; + ba += QByteArray::fromStdString(a.name()) + ", "; + ba += QByteArray::fromStdString(a.uid()); ba += ")"; return qstrdup(ba.data()); } template<> char *toString(const std::vector &v) { QByteArray ba = "vector("; for (std::size_t i = 0; i < v.size(); i++) { ba += QByteArray(toString(v.at(i)))+ "\n"; } ba += ")"; return qstrdup(ba.data()); } template<> char *toString(const Kolab::Attendee &a) { QByteArray ba = "Kolab::Attendee("; - ba += QString::fromStdString(a.contact().email()).toAscii() + "\n"; - ba += QString::fromStdString(a.contact().name()).toAscii()+ "\n"; + ba += QByteArray::fromStdString(a.contact().email()) + "\n"; + ba += QByteArray::fromStdString(a.contact().name()) + "\n"; ba += QByteArray::number(a.partStat()) + "\n"; ba += QByteArray::number(a.role()) + "\n"; ba += QByteArray::number(a.rsvp()) + "\n"; - ba += QString::fromStdString(a.contact().uid()).toAscii()+"\n"; + ba += QByteArray::fromStdString(a.contact().uid())+"\n"; ba += QByteArray(toString(a.delegatedTo()))+"\n"; ba += QByteArray(toString(a.delegatedFrom()))+ "\n"; ba += QByteArray::number(a.cutype())+ "\n"; ba += ")"; return qstrdup(ba.data()); } template<> char *toString(const std::vector &v) { QByteArray ba = "vector("; for (std::size_t i = 0; i < v.size(); i++) { ba += QByteArray(toString(v.at(i)))+ "\n"; ba += QByteArray("#######################")+ "\n"; } ba += ")"; return qstrdup(ba.data()); } template<> char *toString(const Kolab::CustomProperty &a) { QByteArray ba = "Kolab::CustomProperty("; - ba += QString::fromStdString(a.identifier).toAscii()+ ", "; - ba += QString::fromStdString(a.value).toAscii(); + ba += QByteArray::fromStdString(a.identifier) + ", "; + ba += QByteArray::fromStdString(a.value); ba += ")"; return qstrdup(ba.data()); } template<> char *toString(const std::vector &v) { QByteArray ba = "vector("; for (std::size_t i = 0; i < v.size(); i++) { ba += QByteArray(toString(v.at(i)))+ "\n"; } ba += ")"; return qstrdup(ba.data()); } template<> char *toString(const Kolab::Period &p) { QByteArray ba = "Kolab::Period("; ba += QByteArray(toString(p.start))+ "\n"; ba += QByteArray(toString(p.end))+ "\n"; ba += ")"; return qstrdup(ba.data()); } template<> char *toString(const std::vector &v) { QByteArray ba = "vector("; for (std::size_t i = 0; i < v.size(); i++) { ba += QByteArray(toString(v.at(i)))+ "\n"; } ba += ")"; return qstrdup(ba.data()); } template<> char *toString(const Kolab::FreebusyPeriod &p) { QByteArray ba = "Kolab::FreebusyPeriod("; - ba += QString::number(p.type())+ "\n"; - ba += QString::fromStdString(p.eventUid())+ "\n"; - ba += QString::fromStdString(p.eventLocation())+ "\n"; - ba += QString::fromStdString(p.eventSummary())+ "\n"; + ba += QByteArray::number(p.type())+ "\n"; + ba += QByteArray::fromStdString(p.eventUid())+ "\n"; + ba += QByteArray::fromStdString(p.eventLocation())+ "\n"; + ba += QByteArray::fromStdString(p.eventSummary())+ "\n"; ba += QByteArray(toString(p.periods()))+ "\n"; ba += ")"; return qstrdup(ba.data()); } template<> char *toString(const Kolab::Duration &p) { QByteArray ba = "Kolab::Duration"; ba += p.isNegative() ? "-": "+"; ba += "("; - ba += QString::number(p.weeks())+ ", "; - ba += QString::number(p.days())+ ", "; - ba += QString::number(p.hours())+ ", "; - ba += QString::number(p.minutes())+ ", "; - ba += QString::number(p.seconds()); + ba += QByteArray::number(p.weeks())+ ", "; + ba += QByteArray::number(p.days())+ ", "; + ba += QByteArray::number(p.hours())+ ", "; + ba += QByteArray::number(p.minutes())+ ", "; + ba += QByteArray::number(p.seconds()); ba += ")"; return qstrdup(ba.data()); } } #endif