2
This file is part of the Nepomuk KDE project.
3
Copyright (C) 2011 Serebriyskiy Artem <v.for.vandal@gmail.com>
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Lesser General Public
7
License as published by the Free Software Foundation; either
8
version 2.1 of the License, or (at your option) version 3, or any
9
later version accepted by the membership of KDE e.V. (or its
10
successor approved by the membership of KDE e.V.), which shall
11
act as a proxy defined in Section 6 of version 3 of the license.
13
This library is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
Lesser General Public License for more details.
18
You should have received a copy of the GNU Lesser General Public
19
License along with this library. If not, see <http://www.gnu.org/licenses/>.
22
#include "simpleresourceclassestest.h"
27
#include <QDataStream>
28
#include <QtTest/QTest>
30
using namespace Nepomuk2;
32
void SimpleResourceSubsystemTest::initTestCase()
34
resource1.setUri(QUrl("resource1"));
35
resource1.addProperty(QUrl("blablabla"),QString("blablabla"));
36
resource1.addProperty(QUrl("resprg"),SimpleResource(QUrl("another")));
38
resource2.setUri(QUrl("resource2"));
39
resource2.addProperty(QUrl("prop2"),QString("text"));
40
resource2.addProperty(QUrl("prop3"),QVariant(1));
44
void SimpleResourceSubsystemTest::testSimpleResourceStream()
48
QDataStream write_stream(&array,QIODevice::WriteOnly);
50
write_stream << resource1;
53
QDataStream read_stream(array);
54
SimpleResource answer;
55
read_stream >> answer;
57
QCOMPARE(resource1,answer);
61
void SimpleResourceSubsystemTest::testSimpleResourceGraphStream()
63
SimpleResourceGraph refGraph;
64
refGraph.insert(resource1);
65
refGraph.insert(resource2);
68
QDataStream write_stream(&array,QIODevice::WriteOnly);
70
write_stream << refGraph;
73
QDataStream read_stream(array);
74
SimpleResourceGraph answer;
75
read_stream >> answer;
77
QCOMPARE(refGraph,answer);
81
void SimpleResourceSubsystemTest::testSimpleResourceGraphAdd()
83
SimpleResourceGraph refGraph;
84
refGraph.insert(resource1);
85
refGraph.insert(resource2);
86
SimpleResourceGraph graph1;
89
QCOMPARE(graph1,refGraph);
91
SimpleResourceGraph graph2;
97
QCOMPARE(graph2,refGraph);
99
QTEST_MAIN(SimpleResourceSubsystemTest)