<appendix id="test-examples">
<title>Unit Test Examples</title>
<para>
This appendix contains an example of a 
<link linkend="test-header-example">unit test header file listing</link> and a 
<link linkend="test-source-example">unit test source file listing</link>.
</para>

<section id="test-header-example">
<title>Unit Test Header File Example</title>
<screen>

/***************************************************************************
                          mymoneyexceptiontest.h
                          -------------------
    copyright            : (C) 2002 by Thomas Baumgart
    email                : ipwizard@users.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef __MYMONEYEXCEPTIONTEST_H__
#define __MYMONEYEXCEPTIONTEST_H__

#include &lt;QtCore/QObject&gt;

#define KMM_MYMONEY_UNIT_TESTABLE friend class MyMoneyExceptionTest;

#include "mymoneyutils.h"
#include "mymoneyexception.h"

class MyMoneyExceptionTest : public QObject
{
  Q_OBJECT

private slots:
  void init();
  void cleanup();

  void testDefaultConstructor();

  void testConstructor();

};
#endif
</screen>
</section>

<section id="test-source-example">
<title>Unit Test Source File Example</title>

<screen>

/***************************************************************************
                          mymoneyexceptiontest.cpp
                          -------------------
    copyright            : (C) 2002 by Thomas Baumgart
    email                : ipwizard@users.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "mymoneyexceptiontest.h"

#include &lt;QtTest/QtTest&gt;

QTEST_MAIN(MyMoneyExceptionTest)

void MyMoneyExceptionTest::init()
{
}

void MyMoneyExceptionTest::cleanup()
{
}

void MyMoneyExceptionTest::testDefaultConstructor()
{
  const MyMoneyException &amp;e = MYMONEYEXCEPTION("Message");
  QVERIFY(e.what() == "Message");
  QVERIFY(e.line() == __LINE__ - 2);
  QVERIFY(e.file() == __FILE__);
}

void MyMoneyExceptionTest::testConstructor()
{
  MyMoneyException e("New message", "Joe's file", 1234);
  QVERIFY(e.what() == "New message");
  QVERIFY(e.line() == 1234);
  QVERIFY(e.file() == "Joe's file");
}

#include "mymoneyexceptiontest.moc"

</screen>

</section>
</appendix>
