• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeunittest
 

tdeunittest

tester.cpp

00001 /*
00002  * Copyright (C)  2005  Jeroen Wijnhout <Jeroen.Wijnhout@kdemail.net>
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions
00006  * are met:
00007  *
00008  * 1. Redistributions of source code must retain the above copyright
00009  *   notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *   notice, this list of conditions and the following disclaimer in the
00012  *   documentation and/or other materials provided with the distribution.
00013  *
00014  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00015  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00016  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00017  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00018  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00019  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00020  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00021  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00022  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00023  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00024  */
00025 
00026 #include <iostream>
00027 using namespace std;
00028 
00029 #include <tqmetaobject.h>
00030 
00031 #include "tester.h"
00032 
00033 namespace KUnitTest
00034 {
00035     SlotTester::SlotTester(const char *name) : Tester(name)
00036     {
00037         m_resultsList.setAutoDelete(true);
00038         m_total = m_results;
00039     }
00040 
00041     void SlotTester::invokeMember(const TQString &str)
00042     {
00043         TQString slotname = TQString::number(TQSLOT_CODE) + str;
00044         connect(this, TQT_SIGNAL(invoke()), this, slotname.ascii());
00045         emit invoke();
00046         disconnect(this, TQT_SIGNAL(invoke()), this, slotname.ascii());
00047     }
00048     
00049     void SlotTester::allTests()
00050     {
00051         TQStrList allSlots = metaObject()->slotNames();
00052         
00053         if ( allSlots.contains("setUp()") > 0 ) invokeMember("setUp()");
00054 
00055         for ( char *sl = allSlots.first(); sl; sl = allSlots.next() ) 
00056         {
00057             TQString str = sl;
00058            
00059             if ( str.startsWith("test") )
00060             {
00061                 m_results = results(sl);
00062                 m_results->clear();
00063 
00064                 cout << "KUnitTest_Debug_BeginSlot[" << sl << "]" << endl;
00065                 invokeMember(str);
00066                 cout << "KUnitTest_Debug_EndSlot[" << sl << "]" << endl;
00067             }
00068         }
00069 
00070         if ( allSlots.contains("tearDown()") > 0 ) invokeMember("tearDown()");
00071     
00072         m_total->clear();        
00073     }
00074     
00075     TestResults *SlotTester::results(const char *sl) 
00076     {
00077         if ( m_resultsList.find(sl) == 0L ) m_resultsList.insert(sl, new TestResults());
00078     
00079         return m_resultsList[sl]; 
00080     }
00081 }
00082 
00083 TQTextStream& operator<<( TQTextStream& str, const TQRect& r ) {
00084     str << "[" << r.x() << "," << r.y() << " - " << r.width() << "x" << r.height() << "]";
00085     return str;
00086 }
00087 
00088 TQTextStream& operator<<( TQTextStream& str, const TQPoint& r ) {
00089     str << "(" << r.x() << "," << r.y() << ")";
00090     return str;
00091 }
00092 
00093 TQTextStream& operator<<( TQTextStream& str, const TQSize& r ) {
00094     str << "[" << r.width() << "x" << r.height() << "]";
00095     return str;
00096 }
00097 
00098 #include "tester.moc"
00099 

tdeunittest

Skip menu "tdeunittest"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

tdeunittest

Skip menu "tdeunittest"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeunittest by doxygen 1.7.1
This website is maintained by Timothy Pearson.