From 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kmail/tests/messagedicttests.cpp | 79 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 kmail/tests/messagedicttests.cpp (limited to 'kmail/tests/messagedicttests.cpp') diff --git a/kmail/tests/messagedicttests.cpp b/kmail/tests/messagedicttests.cpp new file mode 100644 index 00000000..063fc1cb --- /dev/null +++ b/kmail/tests/messagedicttests.cpp @@ -0,0 +1,79 @@ +/** + * Copyright (C) 2005 Till Adam + * This file is subject to the GPL version 2. + */ + +#include +#include +#include + +#include "kmdict.h" + +#include "messagedicttests.h" + +static void p( const QString & str ) +{ + kdDebug() << str << endl; +} + +void MessageDictTester::setUp() +{ + kdDebug() << "setUp" << endl; + m_dict = new KMDict( 4 ); // will be thrown away in init +} + +void MessageDictTester::tearDown() +{ + kdDebug() << "tearDown" << endl; + delete m_dict; +} + +void MessageDictTester::testKMDictCreation() +{ + p("MessageDictTester::testKMDict()"); + p("Check creation with size of next prime: "); + CHECK( m_dict->size(), 31 ); + m_dict->init( 13 ); // will be created with a 13, no nextPrime() + CHECK( m_dict->size(), 13 ); +} + +void MessageDictTester::testKMDictInsert() +{ + p("Insert: "); + KMDictItem *item = new KMDictItem(); + m_dict->insert( 12345, item ); + KMDictItem *found = m_dict->find( 12345 ); + CHECK( item, found); +} + +void MessageDictTester::testKMDictRemove() +{ + p("Remove: "); + m_dict->remove( 12345 ); + KMDictItem *item = m_dict->find( 12345 ); + CHECK( item, (KMDictItem*)0 ); +} + +void MessageDictTester::testKMDictClear() +{ + p("Check clear: "); + for ( unsigned int i=0; i<11; ++i ) + m_dict->insert( i, new KMDictItem() ); + m_dict->clear(); + CHECK( m_dict->mVecs, (KMDictItem**)0 ); +} + +void MessageDictTester::testKMDictReplace() +{ + p("Check replace: "); + m_dict->init( 31 ); + KMDictItem *oldItem = new KMDictItem(); + KMDictItem *newItem = new KMDictItem(); + m_dict->insert( 12345, oldItem ); + m_dict->replace( 12345, newItem ); + KMDictItem *found = m_dict->find( 12345 ); + CHECK( found, newItem ); +} + +#include "messagedicttests.moc" + -- cgit v1.2.3