File: legacyformattest.cpp

package info (click to toggle)
kdepim-runtime 4%3A20.08.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 25,680 kB
  • sloc: cpp: 94,670; xml: 981; sh: 101; javascript: 60; makefile: 13
file content (56 lines) | stat: -rw-r--r-- 2,001 bytes parent folder | download
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
/*
 * Copyright (C) 2012  Christian Mollekopf <mollekopf@kolabsys.com>
 *
 * 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 <https://www.gnu.org/licenses/>.
 */

#include "legacyformattest.h"
#include "kolabformat/xmlobject.h"
#include "kolabformat/errorhandler.h"
#include "testutils.h"
#include "pimkolab_debug.h"
#include <QTest>
#include <fstream>
#include <sstream>

void V2Test::testReadDistlistUID()
{
    std::ifstream t((TESTFILEDIR.toStdString()+"v2/contacts/distlistWithUID.xml").c_str());
    std::stringstream buffer;
    buffer << t.rdbuf();

    Kolab::XMLObject xo;
    const Kolab::DistList distlist = xo.readDistlist(buffer.str(), Kolab::KolabV2);
    foreach (const Kolab::ContactReference &contact, distlist.members()) {
        QVERIFY(!contact.uid().empty());
    }
    QVERIFY(!Kolab::ErrorHandler::errorOccured());
}

void V2Test::testWriteDistlistUID()
{
    Kolab::DistList distlist;
    distlist.setUid("uid");
    distlist.setName("name");
    std::vector<Kolab::ContactReference> members;
    members.push_back(Kolab::ContactReference(Kolab::ContactReference::UidReference, "memberuid", "membername"));
    distlist.setMembers(members);

    Kolab::XMLObject xo;
    const std::string xml = xo.writeDistlist(distlist, Kolab::KolabV2);
    QVERIFY(QString::fromStdString(xml).contains(QLatin1String("memberuid")));
    QVERIFY(!Kolab::ErrorHandler::errorOccured());
}

QTEST_MAIN(V2Test)