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

« back to all changes in this revision

Viewing changes to kcalcore/tests/testattachment.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2014-01-16 14:37:08 UTC
  • mfrom: (1.3.3)
  • Revision ID: package-import@ubuntu.com-20140116143708-to5k8l8il6534d0f
Tags: 4:4.11.5-0ubuntu0.1
New upstream bugfix release (LP: #1266285)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include "../attachment.h"
24
24
 
25
25
#include <qtest_kde.h>
26
 
QTEST_KDEMAIN( AttachmentTest, NoGUI )
 
26
QTEST_KDEMAIN(AttachmentTest, NoGUI)
27
27
 
28
28
using namespace KCalCore;
29
29
 
30
30
void AttachmentTest::testValidity()
31
31
{
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 );
 
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);
71
71
}