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

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

?? cppunit_cookbook.html

?? c++開發的一個不錯的工具
?? HTML
?? 第 1 頁 / 共 2 頁
字號:
<html><head><title>CppUnit - The Unit Testing Library</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body bgcolor="#ffffff"> <table width="100%">  <tr>    <td width="40%" align="left" valign="center">      <a href="http://sourceforge.net/projects/cppunit">      CppUnit project page      </a>    </td>    <td>      <a href="FAQ">FAQ</a>    </td>    <td width="40%" align="right" valign="center">      <a href="http://cppunit.sourceforge.net">CppUnit home page</a>    </td>  </tr></table><hr><!-- Generated by Doxygen 1.3.7 --><div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div><h1><a class="anchor" name="cppunit_cookbook">CppUnit Cookbook</a></h1>Here is a short cookbook to help you get started.<h2><a class="anchor" name="simple_test_case">Simple Test Case</a></h2>You want to know whether your code is working.<p>How do you do it?<p>There are many ways. Stepping through a debugger or littering your code with stream output calls are two of the simpler ways, but they both have drawbacks. Stepping through your code is a good idea, but it is not automatic. You have to do it every time you make changes. Streaming out text is also fine, but it makes code ugly and it generates far more information than you need most of the time.<p>Tests in CppUnit can be run automatically. They are easy to set up and once you have written them, they are always there to help you keep confidence in the quality of your code.<p>To make a simple test, here is what you do:<p>Subclass the <a class="el" href="">TestCase </a> class. Override the method <a class="el" href="">runTest()</a>. When you want to check a value, call <a class="el" href="group___assertions.html#ga0">CPPUNIT_ASSERT(bool) </a> and pass in an expression that is true if the test succeeds.<p>For example, to test the equality comparison for a Complex number class, write:<p><pre><div class="fragment"><span class="keyword">class </span>ComplexNumberTest : <span class="keyword">public</span> CppUnit::<a class="code" href="class_test_case.html">TestCase</a> { <span class="keyword">public</span>:   ComplexNumberTest( std::string name ) : CppUnit::<a class="code" href="class_test_case.html">TestCase</a>( name ) {}    <span class="keywordtype">void</span> <a class="code" href="class_test_case.html#a5">runTest</a>() {    <a class="code" href="group___assertions.html#ga0">CPPUNIT_ASSERT</a>( Complex (10, 1) == Complex (10, 1) );    <a class="code" href="group___assertions.html#ga0">CPPUNIT_ASSERT</a>( !(Complex (1, 1) == Complex (2, 2)) );  }};</div></pre><p>That was a very simple test. Ordinarily, you'll have many little test cases that you'll want to run on the same set of objects. To do this, use a fixture.<h2><a class="anchor" name="fixture">Fixture</a></h2>A fixture is a known set of objects that serves as a base for a set of test cases. Fixtures come in very handy when you are testing as you develop.<p>Let's try out this style of development and learn about fixtures along the away. Suppose that we are really developing a complex number class. Let's start by defining a empty class named Complex.<p><pre><div class="fragment"><span class="keyword">class </span>Complex {};</div></pre><p>Now create an instance of ComplexNumberTest above, compile the code and see what happens. The first thing we notice is a few compiler errors. The test uses <code>operator ==</code>, but it is not defined. Let's fix that.<p><pre><div class="fragment"><span class="keywordtype">bool</span> operator==( <span class="keyword">const</span> Complex &amp;a, <span class="keyword">const</span> Complex &amp;b) {   <span class="keywordflow">return</span> <span class="keyword">true</span>; }</div></pre><p>Now compile the test, and run it. This time it compiles but the test fails. We need a bit more to get an <code>operator ==</code>working correctly, so we revisit the code.<p><pre><div class="fragment"><span class="keyword">class </span>Complex {   <span class="keyword">friend</span> <span class="keywordtype">bool</span> operator ==(<span class="keyword">const</span> Complex&amp; a, <span class="keyword">const</span> Complex&amp; b);  <span class="keywordtype">double</span> real, imaginary;<span class="keyword">public</span>:  Complex( <span class="keywordtype">double</span> r, <span class="keywordtype">double</span> i = 0 )     : real(r)        , imaginary(i)   {  }};<span class="keywordtype">bool</span> operator ==( <span class="keyword">const</span> Complex &amp;a, <span class="keyword">const</span> Complex &amp;b ){   <span class="keywordflow">return</span> a.real == b.real  &amp;&amp;  a.imaginary == b.imaginary; }</div></pre><p>If we compile now and run our test it will pass.<p>Now we are ready to add new operations and new tests. At this point a fixture would be handy. We would probably be better off when doing our tests if we decided to instantiate three or four complex numbers and reuse them across our tests.<p>Here is how we do it:<ul><li>Add member variables for each part of the <a class="el" href="">fixture </a></li><li>Override <a class="el" href="">setUp() </a> to initialize the variables</li><li>Override <a class="el" href="">tearDown() </a> to release any permanent resources you allocated in <a class="el" href="">setUp() </a></li></ul><p><pre><div class="fragment"><span class="keyword">class </span>ComplexNumberTest : <span class="keyword">public</span> CppUnit::<a class="code" href="class_test_fixture.html">TestFixture</a> {<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> <a class="code" href="class_test_fixture.html#a1">setUp</a>()  {    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> <a class="code" href="class_test_fixture.html#a2">tearDown</a>()   {    <span class="keyword">delete</span> m_10_1;    <span class="keyword">delete</span> m_1_1;    <span class="keyword">delete</span> m_11_2;  }};</div></pre><p>Once we have this fixture, we can add the complex addition test case any any others that we need over the course of our development.<h2><a class="anchor" name="test_case">Test Case</a></h2>How do you write and invoke individual tests using a fixture?<p>There are two steps to this process:<ul><li>Write the test case as a method in the fixture class</li><li>Create a <a class="el" href="class_test_caller.html">TestCaller</a> which runs that particular method</li></ul><p>Here is our test case class with a few extra case methods:<p><pre><div class="fragment"><span class="keyword">class </span>ComplexNumberTest : <span class="keyword">public</span> CppUnit::<a class="code" href="class_test_fixture.html">TestFixture</a>  {<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> <a class="code" href="class_test_fixture.html#a1">setUp</a>()  {    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> <a class="code" href="class_test_fixture.html#a2">tearDown</a>()   {    <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>One may create and run instances for each test case like this:<p><pre><div class="fragment">CppUnit::TestCaller&lt;ComplexNumberTest&gt; test( <span class="stringliteral">"testEquality"</span>,                                              &amp;ComplexNumberTest::testEquality );CppUnit::TestResult result;test.run( &amp;result );</div></pre><p>The second argument to the test caller constructor is the address of a method on ComplexNumberTest. When the test caller is run, that specific method will be run. This is not a useful thing to do, however, as no diagnostics will be displayed. One will normally use a <a class="el" href="group___executing_test.html">TestRunner </a> (see below) to display the results.<p>Once you have several tests, organize them into a suite.<h2><a class="anchor" name="suite">Suite</a></h2>How do you set up your tests so that you can run them all at once?<p>CppUnit provides a <a class="el" href="">TestSuite </a> class that runs any number of TestCases together.<p>We saw, above, how to run a single test case.<p>To create a suite of two or more tests, you do the following:<p><pre><div class="fragment">CppUnit::TestSuite suite;CppUnit::TestResult result;suite.addTest( <span class="keyword">new</span> CppUnit::TestCaller&lt;ComplexNumberTest&gt;(                       <span class="stringliteral">"testEquality"</span>,                        &amp;ComplexNumberTest::testEquality ) );suite.addTest( <span class="keyword">new</span> CppUnit::TestCaller&lt;ComplexNumberTest&gt;(                       <span class="stringliteral">"testAddition"</span>,                        &amp;ComplexNumberTest::testAddition ) );suite.run( &amp;result );</div></pre><p><a class="el" href="">TestSuites </a> don't only have to contain callers for TestCases. They can contain any object that implements the <a class="el" href="">Test </a> interface. For example, you can create a <a class="el" href="">TestSuite </a> in your code and I can create one in mine, and we can run them together by creating a <a class="el" href="">TestSuite </a> that contains both:<p><pre><div class="fragment">CppUnit::TestSuite suite;CppUnit::TestResult result;suite.addTest( ComplexNumberTest::suite() );suite.addTest( SurrealNumberTest::suite() );

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲在线观看免费| 美女视频网站黄色亚洲| 在线播放国产精品二区一二区四区| 丝袜国产日韩另类美女| 国产精品情趣视频| 欧美一区二区三区四区五区| 粉嫩绯色av一区二区在线观看| 亚洲一区二区偷拍精品| 国产精品久久看| 精品日韩一区二区| 91精品国产综合久久香蕉的特点| 成人av电影在线| 国产一区二区三区在线观看免费视频| 亚洲综合成人在线| 亚洲欧洲av在线| 久久久久久久久久看片| 日韩视频在线观看一区二区| 欧美天堂一区二区三区| 91丨九色丨黑人外教| 国产成人精品影视| 精品一区二区三区免费视频| 天天av天天翘天天综合网| 亚洲精品国产精华液| 国产精品国产三级国产aⅴ原创| 久久亚洲综合色| 精品国产123| 日韩亚洲欧美高清| 日韩限制级电影在线观看| 欧美精品日日鲁夜夜添| 欧美视频中文字幕| 色老综合老女人久久久| 99久久国产综合精品女不卡| 国产98色在线|日韩| 国产高清久久久久| 国产不卡视频一区| 国产**成人网毛片九色| 国产高清精品网站| 成人免费毛片片v| 国产成人午夜片在线观看高清观看| 久久不见久久见中文字幕免费| 蜜桃视频一区二区三区| 青青草伊人久久| 日韩成人一级大片| 麻豆免费看一区二区三区| 捆绑调教美女网站视频一区| 久久99久久久久久久久久久| 麻豆91在线播放免费| 日本成人中文字幕| 国产一区在线不卡| 国产成人精品免费视频网站| 成人在线视频一区| 91在线国内视频| 91欧美一区二区| 欧美三级视频在线| 欧美一区二区三区公司| 精品嫩草影院久久| 国产精品日产欧美久久久久| 综合中文字幕亚洲| 亚洲主播在线播放| 婷婷激情综合网| 美女爽到高潮91| 粉嫩嫩av羞羞动漫久久久| 97精品久久久久中文字幕| 欧美视频中文字幕| 精品国产乱码久久| 1区2区3区欧美| 亚洲最新视频在线观看| 日本少妇一区二区| 从欧美一区二区三区| 91久久精品一区二区| 欧美一级二级三级蜜桃| 国产精品乱人伦一区二区| 一区二区三区国产豹纹内裤在线| 香蕉久久一区二区不卡无毒影院 | 欧美曰成人黄网| 91精品视频网| 国产肉丝袜一区二区| 亚洲国产日韩一级| 国产曰批免费观看久久久| 色综合久久九月婷婷色综合| 日韩视频123| 中文字幕亚洲在| 日韩精品电影一区亚洲| 国产91综合网| 88在线观看91蜜桃国自产| 国产日韩欧美a| 天堂资源在线中文精品| av不卡免费电影| 欧美一级免费观看| 亚洲色图欧美在线| 国产一区不卡视频| 欧美日韩情趣电影| 国产精品灌醉下药二区| 日本欧美一区二区三区| 99国内精品久久| 精品国产伦一区二区三区免费| 亚洲三级电影全部在线观看高清| 蜜臀av性久久久久蜜臀av麻豆| 99久久综合色| 久久久国际精品| 肉丝袜脚交视频一区二区| 99热国产精品| 久久午夜羞羞影院免费观看| 亚洲成人精品在线观看| 91丨国产丨九色丨pron| 2020国产精品久久精品美国| 亚洲小说欧美激情另类| 91啪九色porn原创视频在线观看| 久久欧美一区二区| 日本不卡123| 欧美色倩网站大全免费| 亚洲天堂免费在线观看视频| 国产成人在线观看免费网站| 制服丝袜av成人在线看| 一卡二卡欧美日韩| 色综合天天综合网国产成人综合天| 久久免费电影网| 日本美女一区二区| 6080yy午夜一二三区久久| 亚洲精品久久7777| av一区二区不卡| 欧美韩国日本不卡| 国产精品996| 精品电影一区二区| 久久99久久99| 日韩亚洲欧美中文三级| 免费人成精品欧美精品 | 91精品国产全国免费观看| 亚洲精品成人在线| 色噜噜久久综合| 专区另类欧美日韩| 91丨porny丨国产| 亚洲图片另类小说| 91视频一区二区| 亚洲免费在线观看视频| 一本一道久久a久久精品| 国产精品第13页| 91麻豆蜜桃一区二区三区| 综合电影一区二区三区 | 欧美精品乱码久久久久久| 亚洲一卡二卡三卡四卡无卡久久 | 在线不卡一区二区| 日本伊人精品一区二区三区观看方式| 精品视频在线免费看| 五月激情六月综合| 日韩欧美高清dvd碟片| 激情亚洲综合在线| 日本一区二区视频在线观看| 福利一区二区在线观看| 亚洲日本丝袜连裤袜办公室| 色综合久久久久综合| 亚洲精品国产a久久久久久 | 色狠狠一区二区| 亚洲成人动漫在线免费观看| 欧美一区二区精品久久911| 极品少妇一区二区三区精品视频| 久久影院视频免费| 成人一区二区在线观看| 亚洲色图制服诱惑| 91麻豆精品国产自产在线观看一区| 秋霞影院一区二区| 中文字幕巨乱亚洲| 欧美性三三影院| 久久99国产精品尤物| 国产精品麻豆视频| 精品视频色一区| 国产综合色视频| 亚洲欧洲综合另类在线| 欧美日韩精品综合在线| 国产一区免费电影| 亚洲卡通动漫在线| 欧美成人伊人久久综合网| 国产超碰在线一区| 午夜电影网一区| 欧美国产欧美亚州国产日韩mv天天看完整 | 精品日韩99亚洲| 美女一区二区三区| 国产精品女上位| 91麻豆精品国产| 国产91丝袜在线播放| 亚洲不卡av一区二区三区| 久久久综合精品| 欧美色网站导航| 国产风韵犹存在线视精品| 亚洲综合在线观看视频| 2017欧美狠狠色| 欧美色精品在线视频| 粉嫩aⅴ一区二区三区四区| 亚洲国产成人tv| 国产精品久久久久国产精品日日| 91精品国产综合久久香蕉的特点 | 91精品国产综合久久久久久久久久| 国产原创一区二区| 午夜亚洲福利老司机| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 亚洲小说春色综合另类电影| 国产亚洲制服色| 欧美一区欧美二区| 欧美在线免费观看亚洲| 波多野结衣一区二区三区 |