blob: e11bc39153619596379c9c8a90ef55fd937138a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/**
* Copyright (C) 2005 Till Adam <adam@kde.org>
* This file is subject to the GPL version 2.
*/
#include <kdebug.h>
#include <kunittest/runner.h>
#include <kunittest/module.h>
#include "kmdict.h"
#include "messagedicttests.h"
static void p( const TQString & 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->tqfind( 12345 );
CHECK( item, found);
}
void MessageDictTester::testKMDictRemove()
{
p("Remove: ");
m_dict->remove( 12345 );
KMDictItem *item = m_dict->tqfind( 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 tqreplace: ");
m_dict->init( 31 );
KMDictItem *oldItem = new KMDictItem();
KMDictItem *newItem = new KMDictItem();
m_dict->insert( 12345, oldItem );
m_dict->tqreplace( 12345, newItem );
KMDictItem *found = m_dict->tqfind( 12345 );
CHECK( found, newItem );
}
#include "messagedicttests.moc"
|