23
23
#include "../attachment.h"
25
25
#include <qtest_kde.h>
26
QTEST_KDEMAIN( AttachmentTest, NoGUI )
26
QTEST_KDEMAIN(AttachmentTest, NoGUI)
28
28
using namespace KCalCore;
30
30
void AttachmentTest::testValidity()
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() );
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 );
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 );
50
Attachment attachment3( attachment2 );
51
QCOMPARE( attachment3.size(), attachment2.size() );
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() );
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 );
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());
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);
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);
50
Attachment attachment3(attachment2);
51
QCOMPARE(attachment3.size(), attachment2.size());
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());
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);