File indexing completed on 2024-04-21 03:53:37

0001 /*
0002     This file is part of the KContacts framework.
0003     SPDX-FileCopyrightText: 2007 KDE-PIM team <kde-pim@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #include "testutils.h"
0009 #include <QDebug>
0010 #include <converter/kcontacts/vcardconverter.h>
0011 #include <kcontacts/addressee.h>
0012 
0013 #include <stdlib.h>
0014 
0015 using namespace KContacts;
0016 
0017 int main(int, char**)
0018 {
0019     Addressee::List l = vCardsAsAddresseeList();
0020     QByteArray vcards = vCardsAsText();
0021 
0022     VCardConverter vct;
0023 
0024     Addressee::List parsed = vct.parseVCards(vcards);
0025 
0026     if (l.size() != parsed.size()) {
0027         qDebug() << "\tSize - FAILED :" << l.size() << "vs. parsed" << parsed.size();
0028     } else {
0029         qDebug() << "\tSize - PASSED";
0030     }
0031 
0032     Addressee::List::iterator itr1;
0033     Addressee::List::iterator itr2;
0034     // clang-format off
0035     for (itr1 = l.begin(), itr2 = parsed.begin();
0036          itr1 != l.end() && itr2 != parsed.end(); ++itr1, ++itr2) {
0037         if ((*itr1).fullEmail() == (*itr2).fullEmail()
0038             && (*itr1).organization() == (*itr2).organization()
0039             && (*itr1).phoneNumbers() == (*itr2).phoneNumbers()
0040             && (*itr1).emails() == (*itr2).emails()
0041             && (*itr1).role() == (*itr2).role()) {
0042             qDebug() << "\tAddressee  - PASSED";
0043             qDebug() << "\t\t" << (*itr1).fullEmail() << "VS." << (*itr2).fullEmail();
0044             // clang-format on
0045         } else {
0046             qDebug() << "\tAddressee  - FAILED";
0047             qDebug() << (*itr1).toString();
0048             qDebug() << (*itr2).toString();
0049             // qDebug()<<"\t\t"<< (*itr1).fullEmail() << "VS." << (*itr2).fullEmail();
0050         }
0051     }
0052     return EXIT_SUCCESS;
0053 }