<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en_US" xml:lang="en_US"> <head> <title>kunittest: tester.h Source File (kunittest)</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="pics-label" content='(pics-1.1 "http://www.icra.org/ratingsv02.html" comment "ICRAonline DE v2.0" l gen true for "http://www.kde.org" r (nz 1 vz 1 lz 1 oz 1 cb 1) "http://www.rsac.org/ratingsv01.html" l gen true for "http://www.kde.org" r (n 0 s 0 v 0 l 0))' /> <meta name="trademark" content="KDE e.V." /> <meta name="description" content="K Desktop Environment Homepage, KDE.org" /> <meta name="MSSmartTagsPreventParsing" content="true" /> <meta name="robots" content="all" /> <link rel="shortcut icon" href="../../favicon.ico" /> <link rel="stylesheet" media="screen" type="text/css" title="APIDOX" href="doxygen.css" /> </head> <body> <div id="nav_header_top" align="right"> <a href="#content" class="doNotDisplay" accesskey="2">Skip to main content ::</a> <a href="../.."><img id="nav_header_logo" alt="Home" align="left" src="../../kde_gear_64.png" border="0" /></a> <span class="doNotDisplay">::</span> <div id="nav_header_title" align="left">KDE API Reference</div> </div> <div id="nav_header_bottom" align="right"> <span class="doNotDisplay">:: <a href="#navigation" accesskey="5">Skip to Link Menu</a><br/></span> <div id="nav_header_bottom_right" style="text-align: left;"> / <a href="../..">API Reference</a> / <a href=".">kunittest</a> </div> </div> <table id="main" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td valign="top" class="menuheader" height="0"></td> <td id="contentcolumn" valign="top" rowspan="2" > <div id="content" style="padding-top: 0px;"><div style="width:100%; margin: 0px; padding: 0px;"> <a name="content"></a> <!-- Generated by Doxygen 1.7.4 --> <div class="header"> <div class="headertitle"> <div class="title">tester.h</div> </div> </div> <div class="contents"> <a href="tester_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> * tester.h</span> <a name="l00003"></a>00003 <span class="comment"> *</span> <a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 2004 Zack Rusin <zack@kde.org></span> <a name="l00005"></a>00005 <span class="comment"> * Copyright (C) 2005 Jeroen Wijnhout <Jeroen.Wijnhout@kdemail.net></span> <a name="l00006"></a>00006 <span class="comment"> *</span> <a name="l00007"></a>00007 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span> <a name="l00008"></a>00008 <span class="comment"> * modification, are permitted provided that the following conditions</span> <a name="l00009"></a>00009 <span class="comment"> * are met:</span> <a name="l00010"></a>00010 <span class="comment"> *</span> <a name="l00011"></a>00011 <span class="comment"> * 1. Redistributions of source code must retain the above copyright</span> <a name="l00012"></a>00012 <span class="comment"> * notice, this list of conditions and the following disclaimer.</span> <a name="l00013"></a>00013 <span class="comment"> * 2. Redistributions in binary form must reproduce the above copyright</span> <a name="l00014"></a>00014 <span class="comment"> * notice, this list of conditions and the following disclaimer in the</span> <a name="l00015"></a>00015 <span class="comment"> * documentation and/or other materials provided with the distribution.</span> <a name="l00016"></a>00016 <span class="comment"> *</span> <a name="l00017"></a>00017 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR</span> <a name="l00018"></a>00018 <span class="comment"> * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</span> <a name="l00019"></a>00019 <span class="comment"> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.</span> <a name="l00020"></a>00020 <span class="comment"> * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,</span> <a name="l00021"></a>00021 <span class="comment"> * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT</span> <a name="l00022"></a>00022 <span class="comment"> * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span> <a name="l00023"></a>00023 <span class="comment"> * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span> <a name="l00024"></a>00024 <span class="comment"> * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span> <a name="l00025"></a>00025 <span class="comment"> * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF</span> <a name="l00026"></a>00026 <span class="comment"> * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span> <a name="l00027"></a>00027 <span class="comment"> */</span> <a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="preprocessor">#ifndef TESTER_H</span> <a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#define TESTER_H</span> <a name="l00031"></a>00031 <span class="preprocessor"></span> <a name="l00325"></a>00325 <span class="preprocessor">#include <iostream></span> <a name="l00326"></a>00326 <span class="keyword">using namespace </span>std; <a name="l00327"></a>00327 <a name="l00328"></a>00328 <span class="preprocessor">#include <qobject.h></span> <a name="l00329"></a>00329 <span class="preprocessor">#include <qstringlist.h></span> <a name="l00330"></a>00330 <span class="preprocessor">#include <qasciidict.h></span> <a name="l00331"></a>00331 <a name="l00332"></a>00332 <span class="preprocessor">#include <kdelibs_export.h></span> <a name="l00333"></a>00333 <a name="l00339"></a><a class="code" href="tester_8h.html#a4fd95491287cc131e6ae4f5dafc26ac1">00339</a> <span class="preprocessor">#define CHECK( x, y ) check( __FILE__, __LINE__, #x, x, y, false )</span> <a name="l00340"></a>00340 <span class="preprocessor"></span> <a name="l00342"></a><a class="code" href="tester_8h.html#a34d12e2e386464a40aff3b4d9cf7019e">00342</a> <span class="preprocessor">#define COMPARE CHECK</span> <a name="l00343"></a>00343 <span class="preprocessor"></span> <a name="l00345"></a><a class="code" href="tester_8h.html#a3675cf895544424c921cf6f8f5e91887">00345</a> <span class="preprocessor">#define VERIFY( x ) CHECK( x, true )</span> <a name="l00346"></a>00346 <span class="preprocessor"></span> <a name="l00355"></a><a class="code" href="tester_8h.html#a083ae9c5c4eda5232b45ec2e1f8f1801">00355</a> <span class="preprocessor">#define XFAIL( x, y ) check( __FILE__, __LINE__, #x, x, y, true )</span> <a name="l00356"></a>00356 <span class="preprocessor"></span> <a name="l00362"></a><a class="code" href="tester_8h.html#a634ab9b9480188b1ed710cbedd91f156">00362</a> <span class="preprocessor">#define SKIP( x ) skip( __FILE__, __LINE__, QString::fromLatin1(#x))</span> <a name="l00363"></a>00363 <span class="preprocessor"></span> <a name="l00371"></a><a class="code" href="tester_8h.html#a0b66e2c1e37fa4ef3d20468f6c478234">00371</a> <span class="preprocessor">#define CHECK_EXCEPTION(exceptionCatch, expression) \</span> <a name="l00372"></a>00372 <span class="preprocessor"> try \</span> <a name="l00373"></a>00373 <span class="preprocessor"> { \</span> <a name="l00374"></a>00374 <span class="preprocessor"> expression; \</span> <a name="l00375"></a>00375 <span class="preprocessor"> } \</span> <a name="l00376"></a>00376 <span class="preprocessor"> catch(exceptionCatch) \</span> <a name="l00377"></a>00377 <span class="preprocessor"> { \</span> <a name="l00378"></a>00378 <span class="preprocessor"> setExceptionRaised(true); \</span> <a name="l00379"></a>00379 <span class="preprocessor"> } \</span> <a name="l00380"></a>00380 <span class="preprocessor"> if(exceptionRaised()) \</span> <a name="l00381"></a>00381 <span class="preprocessor"> { \</span> <a name="l00382"></a>00382 <span class="preprocessor"> success(QString(__FILE__) + "[" + QString::number(__LINE__) + "]: passed " + #expression); \</span> <a name="l00383"></a>00383 <span class="preprocessor"> } \</span> <a name="l00384"></a>00384 <span class="preprocessor"> else \</span> <a name="l00385"></a>00385 <span class="preprocessor"> { \</span> <a name="l00386"></a>00386 <span class="preprocessor"> failure(QString(__FILE__) + "[" + QString::number(__LINE__) + QString("]: failed to throw " \</span> <a name="l00387"></a>00387 <span class="preprocessor"> "an exception on: ") + #expression); \</span> <a name="l00388"></a>00388 <span class="preprocessor"> } \</span> <a name="l00389"></a>00389 <span class="preprocessor"> setExceptionRaised(false);</span> <a name="l00390"></a>00390 <span class="preprocessor"></span> <a name="l00395"></a><a class="code" href="tester_8h.html#aa9792f7d211cb95f23e38ab30f7aad9d">00395</a> <span class="preprocessor">#define XFAIL_EXCEPTION(exceptionCatch, expression) \</span> <a name="l00396"></a>00396 <span class="preprocessor"> try \</span> <a name="l00397"></a>00397 <span class="preprocessor"> { \</span> <a name="l00398"></a>00398 <span class="preprocessor"> expression; \</span> <a name="l00399"></a>00399 <span class="preprocessor"> } \</span> <a name="l00400"></a>00400 <span class="preprocessor"> catch(exceptionCatch) \</span> <a name="l00401"></a>00401 <span class="preprocessor"> { \</span> <a name="l00402"></a>00402 <span class="preprocessor"> setExceptionRaised(true); \</span> <a name="l00403"></a>00403 <span class="preprocessor"> } \</span> <a name="l00404"></a>00404 <span class="preprocessor"> if(exceptionRaised()) \</span> <a name="l00405"></a>00405 <span class="preprocessor"> { \</span> <a name="l00406"></a>00406 <span class="preprocessor"> unexpectedSuccess(QString(__FILE__) + "[" + QString::number(__LINE__) + "]: unexpectedly threw an exception and passed: " + #expression); \</span> <a name="l00407"></a>00407 <span class="preprocessor"> }\</span> <a name="l00408"></a>00408 <span class="preprocessor"> else \</span> <a name="l00409"></a>00409 <span class="preprocessor"> { \</span> <a name="l00410"></a>00410 <span class="preprocessor"> expectedFailure(QString(__FILE__) + "[" + QString::number(__LINE__) + QString("]: failed to throw an exception on: ") + #expression); \</span> <a name="l00411"></a>00411 <span class="preprocessor"> } \</span> <a name="l00412"></a>00412 <span class="preprocessor"> setExceptionRaised(false);</span> <a name="l00413"></a>00413 <span class="preprocessor"></span> <a name="l00419"></a><a class="code" href="tester_8h.html#a6f8532018c41967598a798ae9e3ed943">00419</a> <span class="preprocessor">#define SKIP_EXCEPTION(exceptionCatch, expression) \</span> <a name="l00420"></a>00420 <span class="preprocessor"> skip( __FILE__, __LINE__, QString("Exception catch: ")\</span> <a name="l00421"></a>00421 <span class="preprocessor"> .arg(QString(#exceptionCatch)).arg(QString(" Test expression: ")).arg(QString(#expression)))</span> <a name="l00422"></a>00422 <span class="preprocessor"></span> <a name="l00426"></a>00426 <span class="keyword">namespace </span>KUnitTest <a name="l00427"></a>00427 { <a name="l00432"></a><a class="code" href="classKUnitTest_1_1TestResults.html">00432</a> <span class="keyword">class </span>KUNITTEST_EXPORT <a class="code" href="classKUnitTest_1_1TestResults.html">TestResults</a> <a name="l00433"></a>00433 { <a name="l00434"></a>00434 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classKUnitTest_1_1Tester.html">Tester</a>; <a name="l00435"></a>00435 <a name="l00436"></a>00436 <span class="keyword">public</span>: <a name="l00437"></a>00437 <a class="code" href="classKUnitTest_1_1TestResults.html">TestResults</a>() : m_tests( 0 ) {} <a name="l00438"></a>00438 <a name="l00439"></a>00439 <span class="keyword">virtual</span> ~<a class="code" href="classKUnitTest_1_1TestResults.html">TestResults</a>() {} <a name="l00440"></a>00440 <a name="l00443"></a><a class="code" href="classKUnitTest_1_1TestResults.html#a5b36078bb4faf886800e5e907d6f87ce">00443</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> clear() <a name="l00444"></a>00444 { <a name="l00445"></a>00445 m_errorList.<a class="code" href="classKUnitTest_1_1TestResults.html#a5b36078bb4faf886800e5e907d6f87ce">clear</a>(); <a name="l00446"></a>00446 m_xfailList.clear(); <a name="l00447"></a>00447 m_xpassList.clear(); <a name="l00448"></a>00448 m_skipList.clear(); <a name="l00449"></a>00449 m_successList.clear(); <a name="l00450"></a>00450 m_debug = <span class="stringliteral">""</span>; <a name="l00451"></a>00451 m_tests = 0; <a name="l00452"></a>00452 } <a name="l00453"></a>00453 <a name="l00457"></a><a class="code" href="classKUnitTest_1_1TestResults.html#a48a34321fbc4d0629d1b5befaf689bad">00457</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> addDebugInfo(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &debug) <a name="l00458"></a>00458 { <a name="l00459"></a>00459 m_debug += debug; <a name="l00460"></a>00460 } <a name="l00461"></a>00461 <a name="l00464"></a><a class="code" href="classKUnitTest_1_1TestResults.html#aecfcd08c0e4c33e76180c9fd8e8dd1da">00464</a> <a class="codeRef" href="qstring.html">QString</a> <a class="code" href="classKUnitTest_1_1TestResults.html#aecfcd08c0e4c33e76180c9fd8e8dd1da">debugInfo</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_debug; } <a name="l00465"></a>00465 <a name="l00467"></a><a class="code" href="classKUnitTest_1_1TestResults.html#a3e5fba6de31feb41a69ad1edf4eda319">00467</a> <span class="keywordtype">int</span> <a class="code" href="classKUnitTest_1_1TestResults.html#a3e5fba6de31feb41a69ad1edf4eda319">testsFinished</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_tests; } <a name="l00468"></a>00468 <a name="l00470"></a><a class="code" href="classKUnitTest_1_1TestResults.html#a9ad030e7703f192ad710661fb1251501">00470</a> <span class="keywordtype">int</span> <a class="code" href="classKUnitTest_1_1TestResults.html#a9ad030e7703f192ad710661fb1251501">errors</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_errorList.count(); } <a name="l00471"></a>00471 <a name="l00473"></a><a class="code" href="classKUnitTest_1_1TestResults.html#a3ff3df9b8c6715baca9d869ff9b3f52d">00473</a> <span class="keywordtype">int</span> <a class="code" href="classKUnitTest_1_1TestResults.html#a3ff3df9b8c6715baca9d869ff9b3f52d">xfails</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_xfailList.count(); } <a name="l00474"></a>00474 <a name="l00476"></a><a class="code" href="classKUnitTest_1_1TestResults.html#a8d18d0cc04ad0a5685f2fe3ced4a76b8">00476</a> <span class="keywordtype">int</span> <a class="code" href="classKUnitTest_1_1TestResults.html#a8d18d0cc04ad0a5685f2fe3ced4a76b8">xpasses</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_xpassList.count(); } <a name="l00477"></a>00477 <a name="l00479"></a><a class="code" href="classKUnitTest_1_1TestResults.html#adfb6d89cb61b5f0de33a64d901075cf2">00479</a> <span class="keywordtype">int</span> <a class="code" href="classKUnitTest_1_1TestResults.html#adfb6d89cb61b5f0de33a64d901075cf2">skipped</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_skipList.count(); } <a name="l00480"></a>00480 <a name="l00482"></a><a class="code" href="classKUnitTest_1_1TestResults.html#a2b305cad31221b45b491c13f48cb5b85">00482</a> <span class="keywordtype">int</span> <a class="code" href="classKUnitTest_1_1TestResults.html#a2b305cad31221b45b491c13f48cb5b85">passed</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_successList.count(); } <a name="l00483"></a>00483 <a name="l00485"></a><a class="code" href="classKUnitTest_1_1TestResults.html#ac356f62f0fc82be7775350f19182c525">00485</a> <a class="codeRef" href="qstringlist.html">QStringList</a> <a class="code" href="classKUnitTest_1_1TestResults.html#ac356f62f0fc82be7775350f19182c525">errorList</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_errorList; } <a name="l00486"></a>00486 <a name="l00488"></a><a class="code" href="classKUnitTest_1_1TestResults.html#a4dea747d02b25d83eee17460e023dd4a">00488</a> <a class="codeRef" href="qstringlist.html">QStringList</a> <a class="code" href="classKUnitTest_1_1TestResults.html#a4dea747d02b25d83eee17460e023dd4a">xfailList</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_xfailList; } <a name="l00489"></a>00489 <a name="l00491"></a><a class="code" href="classKUnitTest_1_1TestResults.html#abc4ca5d8d034aa46321ebd95659feb70">00491</a> <a class="codeRef" href="qstringlist.html">QStringList</a> <a class="code" href="classKUnitTest_1_1TestResults.html#abc4ca5d8d034aa46321ebd95659feb70">xpassList</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_xpassList; } <a name="l00492"></a>00492 <a name="l00494"></a><a class="code" href="classKUnitTest_1_1TestResults.html#a33d07b3b222987031d28c37f2ff8a8ff">00494</a> <a class="codeRef" href="qstringlist.html">QStringList</a> <a class="code" href="classKUnitTest_1_1TestResults.html#a33d07b3b222987031d28c37f2ff8a8ff">skipList</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_skipList; } <a name="l00495"></a>00495 <a name="l00497"></a><a class="code" href="classKUnitTest_1_1TestResults.html#ac783baabe966c41ec6f3057e51890d51">00497</a> <a class="codeRef" href="qstringlist.html">QStringList</a> <a class="code" href="classKUnitTest_1_1TestResults.html#ac783baabe966c41ec6f3057e51890d51">successList</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_successList; } <a name="l00498"></a>00498 <a name="l00499"></a>00499 <span class="keyword">private</span>: <a name="l00500"></a>00500 <a class="codeRef" href="qstringlist.html">QStringList</a> m_errorList; <a name="l00501"></a>00501 <a class="codeRef" href="qstringlist.html">QStringList</a> m_xfailList; <a name="l00502"></a>00502 <a class="codeRef" href="qstringlist.html">QStringList</a> m_xpassList; <a name="l00503"></a>00503 <a class="codeRef" href="qstringlist.html">QStringList</a> m_skipList; <a name="l00504"></a>00504 <a class="codeRef" href="qstringlist.html">QStringList</a> m_successList; <a name="l00505"></a>00505 <a class="codeRef" href="qstring.html">QString</a> m_debug; <a name="l00506"></a>00506 <span class="keywordtype">int</span> m_tests; <a name="l00507"></a>00507 }; <a name="l00508"></a>00508 <a name="l00509"></a>00509 <span class="keyword">typedef</span> <a class="codeRef" href="qasciidict.html">QAsciiDict<TestResults></a> TestResultsListType; <a name="l00510"></a>00510 <a name="l00512"></a><a class="code" href="namespaceKUnitTest.html#a9aedfececa9a1df3b01bc466a446b7f1">00512</a> <span class="keyword">typedef</span> <a class="codeRef" href="qasciidictiterator.html">QAsciiDictIterator<TestResults></a> <a class="code" href="namespaceKUnitTest.html#a9aedfececa9a1df3b01bc466a446b7f1">TestResultsListIteratorType</a>; <a name="l00513"></a>00513 <a name="l00522"></a><a class="code" href="classKUnitTest_1_1Tester.html">00522</a> <span class="keyword">class </span>KUNITTEST_EXPORT <a class="code" href="classKUnitTest_1_1Tester.html">Tester</a> : <span class="keyword">public</span> <a class="codeRef" href="qobject.html">QObject</a> <a name="l00523"></a>00523 { <a name="l00524"></a>00524 <span class="keyword">public</span>: <a name="l00525"></a>00525 <a class="code" href="classKUnitTest_1_1Tester.html">Tester</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *name = 0L) <a name="l00526"></a>00526 : <a class="codeRef" href="qobject.html">QObject</a>(0L, name), m_results(<span class="keyword">new</span> <a class="code" href="classKUnitTest_1_1TestResults.html">TestResults</a>()), m_exceptionState(<span class="keyword">false</span>) <a name="l00527"></a>00527 {} <a name="l00528"></a>00528 <a name="l00529"></a>00529 <span class="keyword">virtual</span> ~<a class="code" href="classKUnitTest_1_1Tester.html">Tester</a>() { <span class="keyword">delete</span> m_results; } <a name="l00530"></a>00530 <a name="l00531"></a>00531 <span class="keyword">public</span>: <a name="l00534"></a>00534 <span class="keyword">virtual</span> <span class="keywordtype">void</span> allTests() = 0; <a name="l00535"></a>00535 <a name="l00536"></a>00536 <span class="keyword">public</span>: <a name="l00539"></a><a class="code" href="classKUnitTest_1_1Tester.html#a15f8d8d441fef63d312bcc303c249024">00539</a> <span class="keyword">virtual</span> <a class="code" href="classKUnitTest_1_1TestResults.html">TestResults</a> *<a class="code" href="classKUnitTest_1_1Tester.html#a15f8d8d441fef63d312bcc303c249024">results</a>() { <span class="keywordflow">return</span> m_results; } <a name="l00540"></a>00540 <a name="l00541"></a>00541 <span class="keyword">protected</span>: <a name="l00547"></a><a class="code" href="classKUnitTest_1_1Tester.html#af11af6833fe78c3e75b2bff19696658a">00547</a> <span class="keywordtype">void</span> skip( <span class="keyword">const</span> <span class="keywordtype">char</span> *file, <span class="keywordtype">int</span> line, <a class="codeRef" href="qstring.html">QString</a> msg ) <a name="l00548"></a>00548 { <a name="l00549"></a>00549 <a class="codeRef" href="qstring.html">QString</a> skipEntry; <a name="l00550"></a>00550 <a class="codeRef" href="qtextstream.html">QTextStream</a> ts( &skipEntry, IO_WriteOnly ); <a name="l00551"></a>00551 ts << file << <span class="stringliteral">"["</span><< line <<<span class="stringliteral">"]: "</span> << msg; <a name="l00552"></a>00552 skipTest( skipEntry ); <a name="l00553"></a>00553 } <a name="l00554"></a>00554 <a name="l00563"></a>00563 <span class="keyword">template</span><<span class="keyword">typename</span> T> <a name="l00564"></a><a class="code" href="classKUnitTest_1_1Tester.html#a6235623cf49304040e1f730d846e053c">00564</a> <span class="keywordtype">void</span> check( <span class="keyword">const</span> <span class="keywordtype">char</span> *file, <span class="keywordtype">int</span> line, <span class="keyword">const</span> <span class="keywordtype">char</span> *str, <a name="l00565"></a>00565 <span class="keyword">const</span> T &result, <span class="keyword">const</span> T &expectedResult, <a name="l00566"></a>00566 <span class="keywordtype">bool</span> expectedFail ) <a name="l00567"></a>00567 { <a name="l00568"></a>00568 cout << <span class="stringliteral">"check: "</span> << file << <span class="stringliteral">"["</span><< line <<<span class="stringliteral">"]"</span> << endl; <a name="l00569"></a>00569 <a name="l00570"></a>00570 <span class="keywordflow">if</span> ( result != expectedResult ) <a name="l00571"></a>00571 { <a name="l00572"></a>00572 <a class="codeRef" href="qstring.html">QString</a> error; <a name="l00573"></a>00573 <a class="codeRef" href="qtextstream.html">QTextStream</a> ts( &error, IO_WriteOnly ); <a name="l00574"></a>00574 ts << file << <span class="stringliteral">"["</span><< line <<<span class="stringliteral">"]: failed on \""</span> << str <a name="l00575"></a>00575 <<<span class="stringliteral">"\" result = '"</span> << result << <span class="stringliteral">"' expected = '"</span> << expectedResult << <span class="stringliteral">"'"</span>; <a name="l00576"></a>00576 <a name="l00577"></a>00577 <span class="keywordflow">if</span> ( expectedFail ) <a name="l00578"></a>00578 expectedFailure( error ); <a name="l00579"></a>00579 <span class="keywordflow">else</span> <a name="l00580"></a>00580 failure( error ); <a name="l00581"></a>00581 <a name="l00582"></a>00582 } <a name="l00583"></a>00583 <span class="keywordflow">else</span> <a name="l00584"></a>00584 { <a name="l00585"></a>00585 <span class="comment">// then the test passed, but we want to record it if</span> <a name="l00586"></a>00586 <span class="comment">// we were expecting a failure</span> <a name="l00587"></a>00587 <span class="keywordflow">if</span> (expectedFail) <a name="l00588"></a>00588 { <a name="l00589"></a>00589 <a class="codeRef" href="qstring.html">QString</a> err; <a name="l00590"></a>00590 <a class="codeRef" href="qtextstream.html">QTextStream</a> ts( &err, IO_WriteOnly ); <a name="l00591"></a>00591 ts << file << <span class="stringliteral">"["</span><< line <<<span class="stringliteral">"]: "</span> <a name="l00592"></a>00592 <<<span class="stringliteral">" unexpectedly passed on \""</span> <a name="l00593"></a>00593 << str <<<span class="stringliteral">"\""</span>; <a name="l00594"></a>00594 unexpectedSuccess( err ); <a name="l00595"></a>00595 } <a name="l00596"></a>00596 <span class="keywordflow">else</span> <a name="l00597"></a>00597 { <a name="l00598"></a>00598 <a class="codeRef" href="qstring.html">QString</a> succ; <a name="l00599"></a>00599 <a class="codeRef" href="qtextstream.html">QTextStream</a> ts( &succ, IO_WriteOnly ); <a name="l00600"></a>00600 ts << file << <span class="stringliteral">"["</span><< line <<<span class="stringliteral">"]: "</span> <a name="l00601"></a>00601 <<<span class="stringliteral">" passed \""</span> <a name="l00602"></a>00602 << str <<<span class="stringliteral">"\""</span>; <a name="l00603"></a>00603 success( succ ); <a name="l00604"></a>00604 } <a name="l00605"></a>00605 } <a name="l00606"></a>00606 <a name="l00607"></a>00607 ++m_results->m_tests; <a name="l00608"></a>00608 } <a name="l00609"></a>00609 <a name="l00617"></a><a class="code" href="classKUnitTest_1_1Tester.html#aa0426549c18f8202a299b962cf3439f7">00617</a> <span class="keywordtype">void</span> <a class="code" href="classKUnitTest_1_1Tester.html#aa0426549c18f8202a299b962cf3439f7">success</a>(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &message) { m_results->m_successList.append(message); } <a name="l00618"></a>00618 <a name="l00626"></a><a class="code" href="classKUnitTest_1_1Tester.html#ac6766b0dd559139fbe63ca7a9a51dd45">00626</a> <span class="keywordtype">void</span> <a class="code" href="classKUnitTest_1_1Tester.html#ac6766b0dd559139fbe63ca7a9a51dd45">failure</a>(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &message) { m_results->m_errorList.append(message); } <a name="l00627"></a>00627 <a name="l00635"></a><a class="code" href="classKUnitTest_1_1Tester.html#a76b79cbb6eeaa404e33cc1896195cdd1">00635</a> <span class="keywordtype">void</span> <a class="code" href="classKUnitTest_1_1Tester.html#a76b79cbb6eeaa404e33cc1896195cdd1">expectedFailure</a>(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &message) { m_results->m_xfailList.append(message); } <a name="l00636"></a>00636 <a name="l00644"></a><a class="code" href="classKUnitTest_1_1Tester.html#aec2ccc17cdbb1a5991bc4648530daebe">00644</a> <span class="keywordtype">void</span> <a class="code" href="classKUnitTest_1_1Tester.html#aec2ccc17cdbb1a5991bc4648530daebe">unexpectedSuccess</a>(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &message) { m_results->m_xpassList.append(message); } <a name="l00645"></a>00645 <a name="l00653"></a><a class="code" href="classKUnitTest_1_1Tester.html#abc4f86c944cab5de4c66880f1a8abe2a">00653</a> <span class="keywordtype">void</span> <a class="code" href="classKUnitTest_1_1Tester.html#abc4f86c944cab5de4c66880f1a8abe2a">skipTest</a>(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &message) { m_results->m_skipList.append(message); } <a name="l00654"></a>00654 <a name="l00662"></a><a class="code" href="classKUnitTest_1_1Tester.html#ae5ac649eceaabf3437aeecb26984bbb8">00662</a> <span class="keywordtype">void</span> <a class="code" href="classKUnitTest_1_1Tester.html#ae5ac649eceaabf3437aeecb26984bbb8">setExceptionRaised</a>(<span class="keywordtype">bool</span> state) { m_exceptionState = state; } <a name="l00663"></a>00663 <a name="l00669"></a><a class="code" href="classKUnitTest_1_1Tester.html#ae5bd5ef1083bd8b16e1335c568cbd5d4">00669</a> <span class="keywordtype">bool</span> exceptionRaised()<span class="keyword"> const</span> <a name="l00670"></a>00670 <span class="keyword"> </span>{ <a name="l00671"></a>00671 <span class="keywordflow">return</span> m_exceptionState; <a name="l00672"></a>00672 } <a name="l00673"></a>00673 <a name="l00674"></a>00674 <span class="keyword">protected</span>: <a name="l00675"></a>00675 <a class="code" href="classKUnitTest_1_1TestResults.html">TestResults</a> *m_results; <a name="l00676"></a>00676 <a name="l00677"></a>00677 <span class="keyword">private</span>: <a name="l00678"></a>00678 <a name="l00679"></a>00679 <span class="keywordtype">bool</span> m_exceptionState; <a name="l00680"></a>00680 }; <a name="l00681"></a>00681 <a name="l00686"></a><a class="code" href="classKUnitTest_1_1SlotTester.html">00686</a> <span class="keyword">class </span>KUNITTEST_EXPORT <a class="code" href="classKUnitTest_1_1SlotTester.html">SlotTester</a> : <span class="keyword">public</span> <a class="code" href="classKUnitTest_1_1Tester.html">Tester</a> <a name="l00687"></a>00687 { <a name="l00688"></a>00688 Q_OBJECT <a name="l00689"></a>00689 <a name="l00690"></a>00690 <span class="keyword">public</span>: <a name="l00691"></a>00691 <a class="code" href="classKUnitTest_1_1SlotTester.html">SlotTester</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *name = 0L); <a name="l00692"></a>00692 <a name="l00693"></a>00693 <span class="keywordtype">void</span> allTests(); <a name="l00694"></a>00694 <a name="l00695"></a>00695 <a class="code" href="classKUnitTest_1_1TestResults.html">TestResults</a> *results(<span class="keyword">const</span> <span class="keywordtype">char</span> *sl); <a name="l00696"></a>00696 <a name="l00697"></a>00697 <a class="codeRef" href="qasciidict.html">TestResultsListType</a> &resultsList() { <span class="keywordflow">return</span> m_resultsList; } <a name="l00698"></a>00698 <a name="l00699"></a>00699 signals: <a name="l00700"></a>00700 <span class="keywordtype">void</span> invoke(); <a name="l00701"></a>00701 <a name="l00702"></a>00702 <span class="keyword">private</span>: <a name="l00703"></a>00703 <span class="keywordtype">void</span> invokeMember(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &str); <a name="l00704"></a>00704 <a name="l00705"></a>00705 <a class="codeRef" href="qasciidict.html">TestResultsListType</a> m_resultsList; <a name="l00706"></a>00706 <a class="code" href="classKUnitTest_1_1TestResults.html">TestResults</a> *m_total; <a name="l00707"></a>00707 }; <a name="l00708"></a>00708 } <a name="l00709"></a>00709 <a name="l00710"></a>00710 KUNITTEST_EXPORT <a class="codeRef" href="qtextstream.html">QTextStream</a>& operator<<( <a class="codeRef" href="qtextstream.html">QTextStream</a>& str, <span class="keyword">const</span> <a class="codeRef" href="qrect.html">QRect</a>& r ); <a name="l00711"></a>00711 <a name="l00712"></a>00712 KUNITTEST_EXPORT <a class="codeRef" href="qtextstream.html">QTextStream</a>& operator<<( <a class="codeRef" href="qtextstream.html">QTextStream</a>& str, <span class="keyword">const</span> <a class="codeRef" href="qpoint.html">QPoint</a>& r ); <a name="l00713"></a>00713 <a name="l00714"></a>00714 KUNITTEST_EXPORT <a class="codeRef" href="qtextstream.html">QTextStream</a>& operator<<( <a class="codeRef" href="qtextstream.html">QTextStream</a>& str, <span class="keyword">const</span> <a class="codeRef" href="qsize.html">QSize</a>& r ); <a name="l00715"></a>00715 <a name="l00716"></a>00716 <span class="preprocessor">#endif</span> </pre></div></div> </div> </div></div> </td> </tr> <tr> <td valign="top" id="leftmenu" width="25%"> <a name="navigation"></a> <div class="menu_box"><h2>kunittest</h2> <div class="nav_list"> <ul><li><a href="index.html">Main Page</a></li><li><a href="namespaces.html">Namespace List</a></li><li><a href="hierarchy.html">Class Hierarchy</a></li><li><a href="classes.html">Alphabetical List</a></li><li><a href="annotated.html">Class List</a></li><li><a href="files.html">File List</a></li><li><a href="namespacemembers.html">Namespace Members</a></li><li><a href="functions.html">Class Members</a></li></ul> <!-- <h2>Class Picker</h2> <div style="text-align: center;"> <form name="guideform"> <select name="guidelinks" style="width:100%;" onChange="window.location=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value"> <option value="annotated.html">-- Choose --</option> <option value="classKUnitTest_1_1Runner.html">kunittest::runner</option>, <option value="classKUnitTest_1_1SlotTester.html">kunittest::slottester</option>, <option value="classKUnitTest_1_1Tester.html">kunittest::tester</option>, <option value="classKUnitTest_1_1TesterAutoregister.html">kunittest::testerautoregister</option>, <option value="classKUnitTest_1_1TestResults.html">kunittest::testresults</option>, </select> </form> </div> --> </div></div> <div class="menu_box"><h2>API Dox</h2> <div class="nav_list"> <ul> <li><a href="../../arts/html/index.html">arts</a></li><li><a href="../../dcop/html/index.html">dcop</a></li><li><a href="../../dnssd/html/index.html">dnssd</a></li><li><a href="../../interfaces/html/index.html">interfaces</a></li><li> <a href="../../interfaces/kimproxy/interface/html/index.html">interface</a></li><li> <a href="../../interfaces/kimproxy/library/html/index.html">library</a></li><li> <a href="../../interfaces/kspeech/html/index.html">kspeech</a></li><li> <a href="../../interfaces/ktexteditor/html/index.html">ktexteditor</a></li><li><a href="../../kabc/html/index.html">kabc</a></li><li><a href="../../kate/html/index.html">kate</a></li><li><a href="../../kcmshell/html/index.html">kcmshell</a></li><li><a href="../../kdecore/html/index.html">kdecore</a></li><li><a href="../../kded/html/index.html">kded</a></li><li><a href="../../kdefx/html/index.html">kdefx</a></li><li><a href="../../kdeprint/html/index.html">kdeprint</a></li><li><a href="../../kdesu/html/index.html">kdesu</a></li><li><a href="../../kdeui/html/index.html">kdeui</a></li><li><a href="../../kdoctools/html/index.html">kdoctools</a></li><li><a href="../../khtml/html/index.html">khtml</a></li><li><a href="../../kimgio/html/index.html">kimgio</a></li><li><a href="../../kinit/html/index.html">kinit</a></li><li><a href="../../kio/html/index.html">kio</a></li><li> <a href="../../kio/bookmarks/html/index.html">bookmarks</a></li><li> <a href="../../kio/httpfilter/html/index.html">httpfilter</a></li><li> <a href="../../kio/kfile/html/index.html">kfile</a></li><li> <a href="../../kio/kio/html/index.html">kio</a></li><li> <a href="../../kio/kioexec/html/index.html">kioexec</a></li><li> <a href="../../kio/kpasswdserver/html/index.html">kpasswdserver</a></li><li> <a href="../../kio/kssl/html/index.html">kssl</a></li><li><a href="../../kioslave/html/index.html">kioslave</a></li><li> <a href="../../kioslave/http/html/index.html">http</a></li><li><a href="../../kjs/html/index.html">kjs</a></li><li><a href="../../kmdi/html/index.html">kmdi</a></li><li> <a href="../../kmdi/kmdi/html/index.html">kmdi</a></li><li><a href="../../knewstuff/html/index.html">knewstuff</a></li><li><a href="../../kparts/html/index.html">kparts</a></li><li><a href="../../kresources/html/index.html">kresources</a></li><li><a href="../../kspell2/html/index.html">kspell2</a></li><li><a href="../../kunittest/html/index.html">kunittest</a></li><li><a href="../../kutils/html/index.html">kutils</a></li><li><a href="../../kwallet/html/index.html">kwallet</a></li><li><a href="../../libkmid/html/index.html">libkmid</a></li><li><a href="../../libkscreensaver/html/index.html">libkscreensaver</a></li> </ul></div></div> </td> </tr> </table> <span class="doNotDisplay"> <a href="http://www.kde.org/" accesskey="8">KDE Home</a> | <a href="http://accessibility.kde.org/" accesskey="9">KDE Accessibility Home</a> | <a href="http://www.kde.org/media/accesskeys.php" accesskey="0">Description of Access Keys</a> </span> <div style="height: 8px"></div> <div id="footer"> <div id="footer_left"> Maintained by <a href="mailto:groot@kde.org">Adriaan de Groot</a> and <a href="mailto:winter@kde.org">Allen Winter</a>. <br/> KDE and K Desktop Environment are trademarks of <a href="http://www.kde.org/areas/kde-ev/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> | <a href="http://www.kde.org/contact/impressum.php">Legal</a> </div> <div id="footer_right"><img src="/media/images/footer_right.png" style="margin: 0px" alt="" /></div> </div> <!-- WARNING: DO NOT SEND MAIL TO THE FOLLOWING EMAIL ADDRESS! YOU WILL BE BLOCKED INSTANTLY AND PERMANENTLY! <a href="mailto:aaaatrap-425acc3b5374943f@kde.org">Block me</a> WARNING END --> </body> </html>