Skip to content

Commit c4c2443

Browse files
committed
Add sample test for Fish
1 parent 9d2f035 commit c4c2443

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

assignments/08-cor-constructive/index.html

+18
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,24 @@ <h2><a class="anchor" id="autotoc_md5"></a>
102102
<div class="line"> <span class="keywordtype">int</span> value = 5;</div>
103103
<div class="line"> EXPECT_EQ(5, value);</div>
104104
<div class="line">}</div>
105+
</div><!-- fragment --><p>and another one based on the <a class="el" href="classFish.html" title="Represents the position and velocity of a Shape on an infinite x-y grid.">Fish</a> class:</p>
106+
<div class="fragment"><div class="line">UTEST(FishTests, DrawWritesToScreen) {</div>
107+
<div class="line"> <a class="code" href="classShape.html">Shape</a> shape({<span class="stringliteral">&quot;&lt;&gt;&lt;&quot;</span>});</div>
108+
<div class="line"> <a class="code" href="classFish.html">Fish</a> fish(shape, 0, 0, 0, 0);</div>
109+
<div class="line"> <a class="code" href="classStringScreen.html">StringScreen</a> screen(5, 5);</div>
110+
<div class="line"> fish.draw(&amp;screen);</div>
111+
<div class="line"> std::string actual = screen.toString();</div>
112+
<div class="line"> EXPECT_STREQ(actual.c_str(), R<span class="stringliteral">&quot;(+-----+</span></div>
113+
<div class="line"><span class="stringliteral">|&lt;&gt;&lt; |</span></div>
114+
<div class="line"><span class="stringliteral">| |</span></div>
115+
<div class="line"><span class="stringliteral">| |</span></div>
116+
<div class="line"><span class="stringliteral">| |</span></div>
117+
<div class="line"><span class="stringliteral">| |</span></div>
118+
<div class="line"><span class="stringliteral">+-----+)&quot;);</span></div>
119+
<div class="line"><span class="stringliteral">}</span></div>
120+
<div class="ttc" id="aclassFish_html"><div class="ttname"><a href="classFish.html">Fish</a></div><div class="ttdoc">Represents the position and velocity of a Shape on an infinite x-y grid.</div><div class="ttdef"><b>Definition:</b> <a href="fish_8h_source.html#l00009">fish.h:9</a></div></div>
121+
<div class="ttc" id="aclassShape_html"><div class="ttname"><a href="classShape.html">Shape</a></div><div class="ttdoc">Represents an ASCII-art drawing and its corresponding bounding box.</div><div class="ttdef"><b>Definition:</b> <a href="shape_8h_source.html#l00007">shape.h:7</a></div></div>
122+
<div class="ttc" id="aclassStringScreen_html"><div class="ttname"><a href="classStringScreen.html">StringScreen</a></div><div class="ttdoc">Serializable implementation of Screen using a 2D character buffer.</div><div class="ttdef"><b>Definition:</b> <a href="string-screen_8h_source.html#l00013">string-screen.h:13</a></div></div>
105123
</div><!-- fragment --><p>All the tests in a file should be part of the same <em>test case</em>, meaning the first argument to each UTEST macro (<code>SampleTestSuite</code>, in this example) should match. It's conventional to name the test case after the class being tested, for example <code>TankTests</code> or <code>FishTests</code>.</p>
106124
<p>You should expect to write many tests for each class. Although the code is relatively simple, there's still a lot that could go wrong, and we'll be running your unit tests to make sure they catch a variety of issues (see next section). The files you provide will likely contain several hundred lines of code in total, although some of this will be <code>UTEST()</code> macros and setup code that's common to multiple tests.</p>
107125
<h1><a class="anchor" id="autotoc_md6"></a>

0 commit comments

Comments
 (0)