亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cppunit_cookbook.html

?? c++開發(fā)的一個不錯的工具
?? HTML
?? 第 1 頁 / 共 2 頁
字號:
suite.run( &amp;result );</div></pre><h2><a class="anchor" name="test_runner">TestRunner</a></h2>How do you run your tests and collect their results?<p>Once you have a test suite, you'll want to run it. CppUnit provides tools to define the suite to be run and to display its results. You make your suite accessible to a <a class="el" href="group___executing_test.html">TestRunner </a> program with a static method <em>suite</em> that returns a test suite.<p>For example, to make a ComplexNumberTest suite available to a <a class="el" href="group___executing_test.html">TestRunner </a>, add the following code to ComplexNumberTest:<p><pre><div class="fragment"><span class="keyword">public</span>:   <span class="keyword">static</span> CppUnit::Test *suite()  {    CppUnit::TestSuite *suiteOfTests = <span class="keyword">new</span> CppUnit::TestSuite( <span class="stringliteral">"ComplexNumberTest"</span> );    suiteOfTests-&gt;addTest( <span class="keyword">new</span> CppUnit::TestCaller&lt;ComplexNumberTest&gt;(                                    <span class="stringliteral">"testEquality"</span>,                                    &amp;ComplexNumberTest::testEquality ) );    suiteOfTests-&gt;addTest( <span class="keyword">new</span> CppUnit::TestCaller&lt;ComplexNumberTest&gt;(                                   <span class="stringliteral">"testAddition"</span>,                                   &amp;ComplexNumberTest::testAddition ) );    <span class="keywordflow">return</span> suiteOfTests;  }</div></pre><p><a class="anchor" name="test_runner_code"></a> To use the text version, include the header files for the tests in Main.cpp:<p><pre><div class="fragment"><span class="preprocessor">#include &lt;<a class="code" href="cppunit_2ui_2text_2_test_runner_8h.html">cppunit/ui/text/TestRunner.h</a>&gt;</span><span class="preprocessor">#include "ExampleTestCase.h"</span><span class="preprocessor">#include "ComplexNumberTest.h"</span></div></pre><p>And add a call to <a class="el" href="">addTest(CppUnit::Test *) </a> in the <code>main()</code> function:<p><pre><div class="fragment"><span class="keywordtype">int</span> main( <span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv){  CppUnit::TextUi::TestRunner runner;  runner.addTest( ExampleTestCase::suite() );  runner.addTest( ComplexNumberTest::suite() );  runner.run();  <span class="keywordflow">return</span> 0;}</div></pre><p>The <a class="el" href="group___executing_test.html">TestRunner </a> will run the tests. If all the tests pass, you'll get an informative message. If any fail, you'll get the following information:<p><ul><li>The name of the test case that failed</li><li>The name of the source file that contains the test</li><li>The line number where the failure occurred</li><li>All of the text inside the call to <a class="el" href="group___assertions.html#ga0">CPPUNIT_ASSERT()</a> which detected the failure</li></ul><p>CppUnit distinguishes between <em>failures</em> and <em>errors</em>. A failure is anticipated and checked for with assertions. Errors are unanticipated problems like division by zero and other exceptions thrown by the C++ runtime or your code.<h2><a class="anchor" name="helper_macros">Helper Macros</a></h2>As you might have noticed, implementing the fixture static <code>suite()</code> method is a repetitive and error prone task. A <a class="el" href="group___writing_test_fixture.html">Writing test fixture</a> set of macros have been created to automatically implements the static <code>suite()</code> method.<p>The following code is a rewrite of ComplexNumberTest using those macros:<p><pre><div class="fragment"><span class="preprocessor">#include &lt;<a class="code" href="_helper_macros_8h.html">cppunit/extensions/HelperMacros.h</a>&gt;</span><span class="keyword">class </span>ComplexNumberTest : <span class="keyword">public</span> CppUnit::<a class="code" href="class_test_fixture.html">TestFixture</a>  {</div></pre>First, we declare the suite, passing the class name to the macro: <pre><div class="fragment"><a class="code" href="group___writing_test_fixture.html#ga0">CPPUNIT_TEST_SUITE</a>( ComplexNumberTest );</div></pre>The suite created by the static <code>suite()</code> method is named after the class name. Then, we declare each test case of the fixture: <pre><div class="fragment"><a class="code" href="group___writing_test_fixture.html#ga5">CPPUNIT_TEST</a>( testEquality );<a class="code" href="group___writing_test_fixture.html#ga5">CPPUNIT_TEST</a>( testAddition );</div></pre>Finally, we end the suite declaration: <pre><div class="fragment"><a class="code" href="group___writing_test_fixture.html#ga2">CPPUNIT_TEST_SUITE_END</a>();</div></pre>At this point, a method with the following signature has been implemented: <pre><div class="fragment"><span class="keyword">static</span> CppUnit::TestSuite *suite();</div></pre>The rest of the fixture is left unchanged: <pre><div class="fragment"><span class="keyword">private</span>:  Complex *m_10_1, *m_1_1, *m_11_2;<span class="keyword">public</span>:  <span class="keywordtype">void</span> setUp()  {    m_10_1 = <span class="keyword">new</span> Complex( 10, 1 );    m_1_1 = <span class="keyword">new</span> Complex( 1, 1 );    m_11_2 = <span class="keyword">new</span> Complex( 11, 2 );    }  <span class="keywordtype">void</span> tearDown()   {    <span class="keyword">delete</span> m_10_1;    <span class="keyword">delete</span> m_1_1;    <span class="keyword">delete</span> m_11_2;  }  <span class="keywordtype">void</span> testEquality()  {    <a class="code" href="group___assertions.html#ga0">CPPUNIT_ASSERT</a>( *m_10_1 == *m_10_1 );    <a class="code" href="group___assertions.html#ga0">CPPUNIT_ASSERT</a>( !(*m_10_1 == *m_11_2) );  }  <span class="keywordtype">void</span> testAddition()  {    <a class="code" href="group___assertions.html#ga0">CPPUNIT_ASSERT</a>( *m_10_1 + *m_1_1 == *m_11_2 );  }};</div></pre><p>The name of the <a class="el" href="">TestCaller </a> added to the suite are a composition of the fixture name and the method name.<p>In the present case, the names would be: "ComplexNumberTest.testEquality" and "ComplexNumberTest.testAddition".<p>The <a class="el" href="group___writing_test_fixture.html">helper macros </a> help you write comon assertion. For example, to check that ComplexNumber throws a MathException when dividing a number by 0:<ul><li>add the test to the suite using CPPUNIT_TEST_EXCEPTION, specifying the expected exception type.</li><li>write the test case method</li></ul><p><pre><div class="fragment"><a class="code" href="group___writing_test_fixture.html#ga0">CPPUNIT_TEST_SUITE</a>( ComplexNumberTest );<span class="comment">// [...]</span><a class="code" href="group___writing_test_fixture.html#ga6">CPPUNIT_TEST_EXCEPTION</a>( testDivideByZeroThrows, MathException );<a class="code" href="group___writing_test_fixture.html#ga2">CPPUNIT_TEST_SUITE_END</a>();<span class="comment">// [...]</span>  <span class="keywordtype">void</span> testDivideByZeroThrows()  {    <span class="comment">// The following line should throw a MathException.</span>    *m_10_1 / ComplexNumber(0);  }</div></pre><p>If the expected exception is not thrown, then a assertion failure is reported.<h2><a class="anchor" name="test_factory_registry">TestFactoryRegistry</a></h2>The <a class="el" href="class_test_factory_registry.html">TestFactoryRegistry</a> was created to solve two pitfalls:<ul><li>forgetting to add your fixture suite to the test runner (since it is in another file, it is easy to forget)</li><li>compilation bottleneck caused by the inclusion of all test case headers (see <a class="el" href="cppunit_cookbook.html#test_runner_code">previous example</a>)</li></ul><p>The <a class="el" href="class_test_factory_registry.html">TestFactoryRegistry</a> is a place where suites can be registered at initialization time.<p>To register the ComplexNumber suite, in the .cpp file, you add:<p><pre><div class="fragment"><span class="preprocessor">#include &lt;<a class="code" href="_helper_macros_8h.html">cppunit/extensions/HelperMacros.h</a>&gt;</span><a class="code" href="group___creating_test_suite.html#ga0">CPPUNIT_TEST_SUITE_REGISTRATION</a>( ComplexNumberTest );</div></pre><p>Behind the scene, a static variable type of <a class="el" href="">AutoRegisterSuite </a> is declared. On construction, it will <a class="el" href="">register </a> a <a class="el" href="">TestSuiteFactory </a> into the <a class="el" href="">TestFactoryRegistry </a>. The <a class="el" href="">TestSuiteFactory </a> returns the <a class="el" href="">TestSuite </a> returned by ComplexNumber::suite().<p>To run the tests, using the text test runner, we don't need to include the fixture anymore:<p><pre><div class="fragment"><span class="preprocessor">#include &lt;<a class="code" href="_test_factory_registry_8h.html">cppunit/extensions/TestFactoryRegistry.h</a>&gt;</span><span class="preprocessor">#include &lt;<a class="code" href="cppunit_2ui_2text_2_test_runner_8h.html">cppunit/ui/text/TestRunner.h</a>&gt;</span><span class="keywordtype">int</span> main( <span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv){  CppUnit::TextUi::TestRunner runner;</div></pre>First, we retreive the instance of the <a class="el" href="">TestFactoryRegistry </a>: <pre><div class="fragment">  CppUnit::TestFactoryRegistry &amp;registry = CppUnit::TestFactoryRegistry::getRegistry();</div></pre>Then, we obtain and add a new <a class="el" href="">TestSuite </a> created by the <a class="el" href="">TestFactoryRegistry </a> that contains all the test suite registered using <a class="el" href="group___creating_test_suite.html#ga0">CPPUNIT_TEST_SUITE_REGISTRATION()</a>. <pre><div class="fragment">  runner.addTest( registry.makeTest() );  runner.run();  <span class="keywordflow">return</span> 0;}</div></pre><h2><a class="anchor" name="post_build_check">Post-build check</a></h2>Well, now that we have our unit tests running, how about integrating unit testing to our build process ?<p>To do that, the application must returns a value different than 0 to indicate that there was an error.<p><a class="el" href="">TestRunner::run() </a> returns a boolean indicating if the run was successful.<p>Updating our main programm, we obtains: <pre><div class="fragment"><span class="preprocessor">#include &lt;<a class="code" href="_test_factory_registry_8h.html">cppunit/extensions/TestFactoryRegistry.h</a>&gt;</span><span class="preprocessor">#include &lt;<a class="code" href="cppunit_2ui_2text_2_test_runner_8h.html">cppunit/ui/text/TestRunner.h</a>&gt;</span><span class="keywordtype">int</span> main( <span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv){  CppUnit::TextUi::TestRunner runner;  CppUnit::TestFactoryRegistry &amp;registry = CppUnit::TestFactoryRegistry::getRegistry();  runner.addTest( registry.makeTest() );  <span class="keywordtype">bool</span> wasSuccessful = runner.run( <span class="stringliteral">""</span>, <span class="keyword">false</span> );  <span class="keywordflow">return</span> wasSuccessful;}</div></pre><p>Now, you need to run your application after compilation.<p>With Visual C++, this is done in <em>Project Settings/Post-Build step</em>, by adding the following command: <code></code>. It is expanded to the application executable path. Look up the project <code>examples/cppunittest/CppUnitTestMain.dsp</code> which use that technic.<p>Original version by Michael Feathers. Doxygen conversion and update by Baptiste Lepilleur. <hr><table width="100%">  <tr>    <td width="10%" align="left" valign="center">      <a href="http://sourceforge.net">       <img      src="http://sourceforge.net/sflogo.php?group_id=11795"      width="88" height="31" border="0" alt="SourceForge Logo"></a>    </td>    <td width="20%" align="left" valign="center">      hosts this site.    </td>    <td>    </td>    <td align="right" valign="center">      Send comments to:<br>      <a href="mailto:cppunit-devel@lists.sourceforge.net">CppUnit Developers</a>    </td>  </tr></table></body> </html>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产婷婷色一区二区三区四区| 成人免费观看av| 欧美在线free| 亚洲午夜成aⅴ人片| 欧美午夜精品一区二区蜜桃| 亚洲午夜羞羞片| 欧美日韩不卡一区二区| 奇米影视在线99精品| 精品欧美黑人一区二区三区| 九九九精品视频| 国产日产欧产精品推荐色| 粉嫩欧美一区二区三区高清影视| 国产精品一级黄| 国产三区在线成人av| 97超碰欧美中文字幕| 一个色在线综合| 日韩视频免费观看高清完整版在线观看| 欧美成人精品高清在线播放| 国产一区二区三区免费播放| 中文字幕一区二区三区蜜月| 色婷婷综合久久久久中文一区二区| 日韩欧美在线观看一区二区三区| 中文字幕日本不卡| 欧美色视频一区| 韩国女主播成人在线| 日本一区二区三区电影| 99re视频这里只有精品| 日韩在线一区二区三区| 国产亚洲成aⅴ人片在线观看| 日韩av一级电影| 国产三级久久久| 欧美日韩在线直播| 国产白丝网站精品污在线入口| 日韩欧美中文字幕一区| www.在线欧美| 日韩电影在线观看电影| 国产精品久久一卡二卡| 欧美乱熟臀69xxxxxx| 国产成人自拍在线| 香蕉成人啪国产精品视频综合网| 色呦呦国产精品| 精品一区二区三区不卡| 一区二区三区小说| 日韩免费高清视频| 在线亚洲一区观看| 国产99久久久精品| 美国av一区二区| 亚洲精选在线视频| 久久综合国产精品| 91精品综合久久久久久| 色综合久久久久综合99| 国产一区二区三区四区五区美女| 国产亚洲欧美日韩俺去了| 欧美日韩高清不卡| 91免费看`日韩一区二区| 国产一区欧美日韩| 美女脱光内衣内裤视频久久影院| 日韩精品在线一区| 欧美日免费三级在线| 不卡视频在线观看| 国产一区二区免费视频| 日本不卡一区二区三区| 亚洲精品一二三四区| 欧美激情综合五月色丁香| 欧美mv日韩mv亚洲| 69堂精品视频| 在线中文字幕一区| 色噜噜狠狠一区二区三区果冻| 亚洲国产日韩在线一区模特| 国产日韩欧美在线一区| 日韩美女视频在线| 91精品国产综合久久精品性色| 狠狠色丁香久久婷婷综合_中| 久久久精品蜜桃| 欧美精品一区二区三区在线 | 国产精品资源在线观看| 天天操天天色综合| 樱桃视频在线观看一区| 亚洲欧美成aⅴ人在线观看| 中文字幕第一区综合| 久久久久国产精品人| 久久精品免视看| 日本一区二区综合亚洲| 久久久国产一区二区三区四区小说 | 亚洲日本在线a| 亚洲欧洲日产国产综合网| 亚洲国产精品激情在线观看| 日本一区二区三区电影| 中文久久乱码一区二区| 中文一区在线播放| 中文字幕在线视频一区| 国产精品久久久久影视| 国产精品网站在线| 亚洲国产精品t66y| 成人欧美一区二区三区在线播放| 欧美日韩电影在线播放| 91精品国产综合久久精品| 欧美日韩午夜在线视频| 在线不卡中文字幕播放| 日韩精品一区在线| 国产午夜亚洲精品羞羞网站| 国产精品久久久久精k8 | jlzzjlzz欧美大全| 99久久99久久综合| 精品视频一区二区三区免费| 正在播放亚洲一区| 日韩免费在线观看| 中文字幕制服丝袜成人av| 亚洲一区二区四区蜜桃| 免费久久99精品国产| 国产白丝网站精品污在线入口| 蜜桃视频在线一区| 成人精品一区二区三区中文字幕| 日韩高清一区在线| 国产精品一二三四五| 色拍拍在线精品视频8848| 欧美一区二区精品久久911| 国产视频一区二区在线观看| 亚洲精品视频在线观看网站| 日本色综合中文字幕| 国v精品久久久网| 欧亚一区二区三区| 亚洲精品一区二区三区精华液 | 日韩av一区二| 国v精品久久久网| 欧美日韩激情一区| 欧美高清在线视频| 奇米精品一区二区三区四区 | 久久嫩草精品久久久精品一| 国产精品久久久久久久久快鸭| 亚洲精品一区二区三区精华液| 欧美精品欧美精品系列| 国产三级精品三级在线专区| 亚洲电影一区二区| 国产宾馆实践打屁股91| 欧美日本一区二区三区| 欧美激情一区二区三区四区| 午夜精品久久久久久久| aaa欧美色吧激情视频| 精品剧情在线观看| 亚洲成人动漫av| 91丨九色丨国产丨porny| 亚洲精品一区二区在线观看| 午夜精品一区在线观看| 99精品视频在线观看免费| 久久综合九色综合97婷婷女人| 久久蜜桃一区二区| 性欧美疯狂xxxxbbbb| 99久久精品免费看国产免费软件| 91老师国产黑色丝袜在线| 亚洲精品在线观看网站| 奇米精品一区二区三区四区| 91麻豆福利精品推荐| 国产精品麻豆视频| 国产99久久久久久免费看农村| 成人av网站在线观看免费| 日韩欧美国产综合一区| 亚洲风情在线资源站| 在线观看不卡视频| 视频在线观看一区| 久久久久久久综合日本| 在线看国产一区| 欧美精品1区2区3区| 亚洲精品国产第一综合99久久| 亚洲三级免费电影| 成人午夜视频在线观看| 日本一区二区三区在线不卡| 精品一区免费av| 精品久久久久久久久久久久久久久久久| 日韩欧美美女一区二区三区| 日韩av在线播放中文字幕| 欧美一级搡bbbb搡bbbb| 日日夜夜一区二区| 欧美一区二区三区在线观看视频| 久久在线观看免费| 狠狠色伊人亚洲综合成人| 久久五月婷婷丁香社区| 国产成人福利片| 国产精品国模大尺度视频| 国产91丝袜在线播放九色| 欧美韩国日本综合| 91丨porny丨最新| 亚洲777理论| 91精品在线免费观看| 另类小说图片综合网| 久久久亚洲精品一区二区三区| 亚洲精品免费一二三区| 在线观看免费视频综合| 丝袜亚洲另类欧美综合| 欧美一二三四在线| 免费成人在线观看视频| www国产成人免费观看视频 深夜成人网| 亚洲色图清纯唯美| 欧美日韩精品一区二区天天拍小说| 精品国产污污免费网站入口| 成人美女视频在线观看18| 中文字幕一区二区三区av| 在线观看视频一区二区| 热久久一区二区| 国产欧美日本一区二区三区|