~ubuntu-branches/ubuntu/saucy/kdepimlibs/saucy-proposed

1.1.55 by Jonathan Thomas
Import upstream version 4.5.80
1
/*
2
  This file is part of the kcalcore library.
3
  Copyright (C) 2006 Allen Winter <winter@kde.org>
4
5
  This library is free software; you can redistribute it and/or
6
  modify it under the terms of the GNU Library General Public
7
  License as published by the Free Software Foundation; either
8
  version 2 of the License, or (at your option) any later version.
9
10
  This library is distributed in the hope that it will be useful,
11
  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
  Library General Public License for more details.
14
15
  You should have received a copy of the GNU Library General Public License
16
  along with this library; see the file COPYING.LIB.  If not, write to
17
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
  Boston, MA 02110-1301, USA.
19
*/
20
21
#include "testattachment.h"
22
#include "../event.h"
23
#include "../attachment.h"
24
25
#include <qtest_kde.h>
1.3.3 by Maximiliano Curia
Import upstream version 4.11.5
26
QTEST_KDEMAIN(AttachmentTest, NoGUI)
1.1.55 by Jonathan Thomas
Import upstream version 4.5.80
27
28
using namespace KCalCore;
29
30
void AttachmentTest::testValidity()
31
{
1.3.3 by Maximiliano Curia
Import upstream version 4.11.5
32
    Attachment attachment(QString("http://www.kde.org"));
33
    QCOMPARE(attachment.uri(), QString::fromLatin1("http://www.kde.org"));
34
    QCOMPARE(attachment.data(), QByteArray());
35
    QVERIFY(attachment.decodedData().isEmpty());
36
    QVERIFY(!attachment.isBinary());
37
38
    attachment.setDecodedData("foo");
39
    QVERIFY(attachment.isBinary());
40
    QCOMPARE(attachment.decodedData(), QByteArray("foo"));
41
    QCOMPARE(attachment.data(), QByteArray("Zm9v"));
42
    QCOMPARE(attachment.size(), 3U);
43
44
    Attachment attachment2 = Attachment(QByteArray("Zm9v"));
45
    QCOMPARE(attachment2.size(), 3U);
46
    QCOMPARE(attachment2.decodedData(), QByteArray("foo"));
47
    attachment2.setDecodedData("123456");
48
    QCOMPARE(attachment2.size(), 6U);
49
50
    Attachment attachment3(attachment2);
51
    QCOMPARE(attachment3.size(), attachment2.size());
52
53
    QByteArray fred("jkajskldfasjfklasjfaskfaskfasfkasfjdasfkasjf");
54
    Attachment attachment4(fred, QByteArray("image/nonsense"));
55
    QCOMPARE(fred, attachment4.data());
56
    QVERIFY(attachment4.isBinary());
57
    QByteArray ethel("a9fafafjafkasmfasfasffksjklfjau");
58
    attachment4.setData(ethel);
59
    QCOMPARE(ethel, attachment4.data());
60
61
    Attachment attachment5(QString("http://www.kde.org"));
62
    Attachment attachment6(QString("http://www.kde.org"));
63
    QVERIFY(attachment5 == attachment6);
64
    attachment5.setUri("http://bugs.kde.org");
65
    QVERIFY(attachment5 != attachment6);
66
    attachment5.setDecodedData("123456");
67
    attachment6.setDecodedData("123456");
68
    QVERIFY(attachment5 == attachment6);
69
    attachment6.setDecodedData("12345");
70
    QVERIFY(attachment5 != attachment6);
1.1.55 by Jonathan Thomas
Import upstream version 4.5.80
71
}