TDE personal information management applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

messagedicttests.cpp 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * Copyright (C) 2005 Till Adam <adam@kde.org>
  3. * This file is subject to the GPL version 2.
  4. */
  5. #include <kdebug.h>
  6. #include <tdeunittest/runner.h>
  7. #include <tdeunittest/module.h>
  8. #include "kmdict.h"
  9. #include "messagedicttests.h"
  10. static void p( const TQString & str )
  11. {
  12. kdDebug() << str << endl;
  13. }
  14. void MessageDictTester::setUp()
  15. {
  16. kdDebug() << "setUp" << endl;
  17. m_dict = new KMDict( 4 ); // will be thrown away in init
  18. }
  19. void MessageDictTester::tearDown()
  20. {
  21. kdDebug() << "tearDown" << endl;
  22. delete m_dict;
  23. }
  24. void MessageDictTester::testKMDictCreation()
  25. {
  26. p("MessageDictTester::testKMDict()");
  27. p("Check creation with size of next prime: ");
  28. CHECK( m_dict->size(), 31 );
  29. m_dict->init( 13 ); // will be created with a 13, no nextPrime()
  30. CHECK( m_dict->size(), 13 );
  31. }
  32. void MessageDictTester::testKMDictInsert()
  33. {
  34. p("Insert: ");
  35. KMDictItem *item = new KMDictItem();
  36. m_dict->insert( 12345, item );
  37. KMDictItem *found = m_dict->find( 12345 );
  38. CHECK( item, found);
  39. }
  40. void MessageDictTester::testKMDictRemove()
  41. {
  42. p("Remove: ");
  43. m_dict->remove( 12345 );
  44. KMDictItem *item = m_dict->find( 12345 );
  45. CHECK( item, (KMDictItem*)0 );
  46. }
  47. void MessageDictTester::testKMDictClear()
  48. {
  49. p("Check clear: ");
  50. for ( unsigned int i=0; i<11; ++i )
  51. m_dict->insert( i, new KMDictItem() );
  52. m_dict->clear();
  53. CHECK( m_dict->mVecs, (KMDictItem**)0 );
  54. }
  55. void MessageDictTester::testKMDictReplace()
  56. {
  57. p("Check replace: ");
  58. m_dict->init( 31 );
  59. KMDictItem *oldItem = new KMDictItem();
  60. KMDictItem *newItem = new KMDictItem();
  61. m_dict->insert( 12345, oldItem );
  62. m_dict->replace( 12345, newItem );
  63. KMDictItem *found = m_dict->find( 12345 );
  64. CHECK( found, newItem );
  65. }
  66. #include "messagedicttests.moc"