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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? cppunit_cookbook.html

?? c++開發(fā)的一個不錯的工具
?? 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() );

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91精品麻豆日日躁夜夜躁| 亚洲高清视频在线| 国产福利不卡视频| 久久综合九色综合97_久久久| 日韩激情在线观看| 日韩视频免费观看高清完整版在线观看 | 欧美区一区二区三区| 亚洲一区在线观看网站| 欧美日本一道本在线视频| 日本午夜一本久久久综合| 精品国产免费一区二区三区四区 | 亚洲已满18点击进入久久| 欧美日本国产视频| 久久国产精品无码网站| 国产亲近乱来精品视频 | 欧美影视一区在线| 日韩国产欧美在线播放| 久久久亚洲午夜电影| 99久久99久久精品免费观看 | 婷婷成人综合网| 久久天堂av综合合色蜜桃网| 成人激情黄色小说| 亚洲妇熟xx妇色黄| 精品国产91乱码一区二区三区 | 久久99热这里只有精品| 国产精品麻豆一区二区| 欧美日韩免费一区二区三区视频| 久久电影国产免费久久电影| 国产精品成人在线观看| 7777精品伊人久久久大香线蕉的| 国产一区啦啦啦在线观看| 自拍视频在线观看一区二区| 欧美美女一区二区| 白白色 亚洲乱淫| 视频在线观看一区| 国产精品国产三级国产三级人妇| 欧美日高清视频| 不卡一二三区首页| 蜜桃视频在线观看一区| 亚洲精品乱码久久久久久日本蜜臀| 日韩午夜电影在线观看| 日本精品一级二级| 国产乱码一区二区三区| 五月天亚洲精品| 亚洲图片你懂的| 久久久久久97三级| 日韩免费视频一区| 欧美揉bbbbb揉bbbbb| 成人精品鲁一区一区二区| 蜜臀a∨国产成人精品| 夜夜嗨av一区二区三区四季av | 91浏览器在线视频| 国产精品1区2区| 高清在线不卡av| 亚洲电影在线免费观看| 中文字幕色av一区二区三区| 久久影院午夜论| 欧美一区二区三区男人的天堂| 色综合久久中文字幕综合网| 国产suv精品一区二区三区| 蜜臀久久久久久久| 三级欧美韩日大片在线看| 亚洲三级在线免费观看| 国产精品丝袜91| 国产亚洲欧美在线| 久久婷婷成人综合色| 精品久久久久香蕉网| 日韩视频123| 欧美一区二区大片| 欧美日韩一级视频| 欧美视频一区在线观看| 欧美亚洲国产bt| 色呦呦日韩精品| 91蜜桃传媒精品久久久一区二区| 成人丝袜18视频在线观看| 国产精品一二三四区| 麻豆久久一区二区| 久久国产欧美日韩精品| 精品无人码麻豆乱码1区2区 | 国产不卡视频在线播放| 狠狠色综合播放一区二区| 精品在线播放免费| 国产美女一区二区| 国产一区二区0| 成人高清视频在线观看| youjizz国产精品| 一本久久a久久精品亚洲| 日本韩国欧美一区二区三区| 欧美午夜免费电影| 欧美一区二区黄色| 精品国产乱码久久久久久1区2区 | 激情丁香综合五月| 国产成人免费视频网站高清观看视频| 久久成人免费网| 国产福利一区二区| 99re成人在线| 欧美日韩成人综合在线一区二区| 欧美精选午夜久久久乱码6080| 日韩一级视频免费观看在线| 久久综合久久久久88| 国产精品麻豆一区二区| 亚洲福利视频一区二区| 美国欧美日韩国产在线播放| 国产伦精一区二区三区| 91在线视频观看| 91精品国产一区二区| 久久久久久久国产精品影院| 欧美精品一区二区三区视频| 国产精品视频一二| 亚洲一区二区av电影| 久久草av在线| 91色在线porny| 欧美一区二区成人6969| 亚洲国产精品99久久久久久久久 | 亚洲欧美日韩成人高清在线一区| 亚洲国产视频直播| 国产伦精品一区二区三区免费迷| 国产**成人网毛片九色| 欧美久久久久久久久久| 国产午夜精品久久久久久久 | 94-欧美-setu| 日韩久久免费av| 亚洲欧美日韩电影| 国产一区二区三区黄视频| 色狠狠色狠狠综合| 亚洲精品一区二区三区精华液| 亚洲欧美另类小说| 国产乱子轮精品视频| 欧美亚洲国产一区二区三区| 国产日韩高清在线| 日韩av不卡一区二区| av电影天堂一区二区在线观看| 欧美一卡二卡三卡| 亚洲男人天堂一区| 国产成人丝袜美腿| 欧美一区二区三区免费观看视频| 国产精品午夜春色av| 久久99久久久久久久久久久| 色香色香欲天天天影视综合网| 2023国产精品自拍| 亚洲成人一区在线| 91原创在线视频| 国产女人水真多18毛片18精品视频 | 成人av小说网| 精品国产成人系列| 日韩综合小视频| 色婷婷久久久综合中文字幕 | 激情欧美一区二区三区在线观看| 欧美系列在线观看| 亚洲少妇中出一区| 国产高清一区日本| 精品99999| 男女激情视频一区| 欧美日韩午夜在线视频| 亚洲免费在线视频一区 二区| 国产成人av一区| 日韩免费性生活视频播放| 日韩二区三区在线观看| 欧美三级三级三级| 亚洲伊人伊色伊影伊综合网| 色综合久久久久综合体| 中文字幕综合网| 成人18视频在线播放| 国产精品久久久久天堂| 国产99精品视频| 欧美韩日一区二区三区| 国产999精品久久久久久| 国产欧美视频一区二区| 国产精品亚洲成人| 国产午夜精品理论片a级大结局| 韩国精品一区二区| 精品盗摄一区二区三区| 国产中文字幕精品| 久久久777精品电影网影网 | 美女国产一区二区三区| 91精品国产aⅴ一区二区| 奇米精品一区二区三区在线观看 | 欧美一区二区福利视频| 看国产成人h片视频| 精品国产一区二区三区av性色| 久久精品国产精品青草| 久久综合色一综合色88| 国产精品伊人色| 亚洲欧洲av色图| 91久久人澡人人添人人爽欧美| 一区二区三区精品视频| 欧美日韩一二三| 男女男精品网站| 国产视频一区不卡| 91免费国产视频网站| 亚洲国产日韩a在线播放性色| 欧美久久久久久久久| 国产一区二区三区观看| 国产精品美女久久久久久久网站| 99re热视频这里只精品| 视频一区中文字幕| 26uuu久久天堂性欧美| a级高清视频欧美日韩| 亚洲一区二区三区爽爽爽爽爽| 日韩一区二区免费在线电影|