Page MenuHomec4science

week8.html
No OneTemporary

File Metadata

Created
Sun, May 19, 13:11

week8.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<title>talk slides</title>
<!-- Loading the init_reveal macro -->
<!-- Load and configure reveal -->
<script src="js-markdown-extra.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<!-- General and theme style sheets -->
<link rel="stylesheet" href="reveal.js/css/reveal.css">
<link rel="stylesheet" href="reveal.js/css/theme/simple.css" id="theme">
<!-- Loading the mathjax macro -->
<!-- Load mathjax -->
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- MathJax configuration -->
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
processEscapes: true,
processEnvironments: true
},
// Center justify equations in code and markdown cells. Elsewhere
// we use CSS to left justify single line equations in code cells.
displayAlign: 'center',
"HTML-CSS": {
styles: {'.MathJax_Display': {"margin": 0}},
linebreaks: { automatic: true }
}
});
</script>
<!-- End of mathjax configuration -->
<!-- Get Font-awesome from cdn -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.css">
<!-- End of reveal parts -->
<style type="text/css">
.reveal {
font-size: 16px;
}
.reveal h1 {
font-size: 200%;
}
.reveal h2 {
font-size: 150%;
}
.text_cell_render {
text-align: left;
}
a.anchor-link:link {
text-decoration: none;
visibility: hidden;
}
.slide {
}
div.slide{
border-style: solid;
border-width: 2px;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
margin-top: 5px;
margin-bottom: 5px;
padding: 100px;
width: 1000px;
}
/*******************************
** highing tpart
*******************************/
.highlight_text {
color: blue;
}
.highlight-base {
color: #000;
}
.highlight-variable {
color: #000;
}
.highlight-variable-2 {
color: #1a1a1a;
}
.highlight-variable-3 {
color: #333333;
}
.highlight-string {
color: #BA2121;
}
.highlight-comment {
color: #408080;
font-style: italic;
}
.highlight-number {
color: #080;
}
.highlight-atom {
color: #88F;
}
.highlight-keyword {
color: #008000;
font-weight: bold;
}
.highlight-builtin {
color: #008000;
}
.highlight-error {
color: #f00;
}
.highlight-operator {
color: #AA22FF;
font-weight: bold;
}
.highlight-meta {
color: #AA22FF;
}
.highlight-def {
color: #00f;
}
.highlight-string-2 {
color: #f50;
}
.highlight-qualifier {
color: #555;
}
.highlight-bracket {
color: #997;
}
.highlight-tag {
color: #170;
}
.highlight-attribute {
color: #00c;
}
.highlight-header {
color: blue;
}
.highlight-quote {
color: #090;
}
.highlight-link {
color: #00c;
}
.highlight .hll { background-color: #ffffcc }
//.highlight { background: #f8f8f8; }
.highlight .c { color: #408080; font-style: italic } /* Comment */
.highlight .err { border: 1px solid #FF0000 } /* Error */
.highlight .k { color: #008000; font-weight: bold } /* Keyword */
.highlight .o { color: #666666 } /* Operator */
.highlight .ch { color: #408080; font-style: italic } /* Comment.Hashbang */
.highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #BC7A00 } /* Comment.Preproc */
.highlight .cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */
.highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */
.highlight .cs { color: #408080; font-style: italic } /* Comment.Special */
.highlight .gd { color: #A00000 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #FF0000 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #00A000 } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.highlight .gt { color: #0044DD } /* Generic.Traceback */
.highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008000 } /* Keyword.Pseudo */
.highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #B00040 } /* Keyword.Type */
.highlight .m { color: #666666 } /* Literal.Number */
.highlight .s { color: #BA2121 } /* Literal.String */
.highlight .na { color: #7D9029 } /* Name.Attribute */
.highlight .nb { color: #008000 } /* Name.Builtin */
.highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */
.highlight .no { color: #880000 } /* Name.Constant */
.highlight .nd { color: #AA22FF } /* Name.Decorator */
.highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */
.highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0000FF } /* Name.Function */
.highlight .nl { color: #A0A000 } /* Name.Label */
.highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #19177C } /* Name.Variable */
.highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #666666 } /* Literal.Number.Bin */
.highlight .mf { color: #666666 } /* Literal.Number.Float */
.highlight .mh { color: #666666 } /* Literal.Number.Hex */
.highlight .mi { color: #666666 } /* Literal.Number.Integer */
.highlight .mo { color: #666666 } /* Literal.Number.Oct */
.highlight .sa { color: #BA2121 } /* Literal.String.Affix */
.highlight .sb { color: #BA2121 } /* Literal.String.Backtick */
.highlight .sc { color: #BA2121 } /* Literal.String.Char */
.highlight .dl { color: #BA2121 } /* Literal.String.Delimiter */
.highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #BA2121 } /* Literal.String.Double */
.highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */
.highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.highlight .sx { color: #008000 } /* Literal.String.Other */
.highlight .sr { color: #BB6688 } /* Literal.String.Regex */
.highlight .s1 { color: #BA2121 } /* Literal.String.Single */
.highlight .ss { color: #19177C } /* Literal.String.Symbol */
.highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0000FF } /* Name.Function.Magic */
.highlight .vc { color: #19177C } /* Name.Variable.Class */
.highlight .vg { color: #19177C } /* Name.Variable.Global */
.highlight .vi { color: #19177C } /* Name.Variable.Instance */
.highlight .vm { color: #19177C } /* Name.Variable.Magic */
.highlight .il { color: #666666 } /* Literal.Number.Integer.Long */
</style>
</head>
<body>
<div class="reveal">
<div class="slides">
<section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h1 id="Documentation">Documentation<a class="anchor-link" href="#Documentation">&#182;</a></h1><ul>
<li>What do you expect for the documentation ?</li>
</ul>
</div>
</div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h1 id="Documentation">Documentation<a class="anchor-link" href="#Documentation">&#182;</a></h1><ul>
<li>For users: <ul>
<li>Examples</li>
<li>Manual</li>
</ul>
</li>
<li>For developpers: API description, procedures, FAQ<ul>
<li>Best way to make an API doc: source annotation</li>
</ul>
</li>
</ul>
</div>
</div></div>
</section></section><section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h1 id="Doxygen"><a href="http://www.doxygen.org/">Doxygen</a><a class="anchor-link" href="#Doxygen">&#182;</a></h1><ul>
<li>It is a standard tool for generating documentation from annotated C++ sources (and many others)</li>
<li>Attached comments will be parsed to form the generated documentation.</li>
<li><a href="https://www.stack.nl/~dimitri/doxygen/manual/docblocks.html">Doxygen documentation</a></li>
<li>installation: <div class="highlight"><pre><span></span>&gt; sudo apt install doxygen graphviz
</pre></div>
</li>
</ul>
</div>
</div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Block-long-annotation">Block long annotation<a class="anchor-link" href="#Block-long-annotation">&#182;</a></h2><div class="highlight"><pre><span></span><span class="cm">/**</span>
<span class="cm"> * ... text ...</span>
<span class="cm"> */</span>
</pre></div>
<p>Example: class documentation:</p>
<div class="highlight"><pre><span></span><span class="cm">/**</span>
<span class="cm"> * This is my super cool class</span>
<span class="cm"> */</span>
<span class="k">class</span> <span class="nc">SuperCoolClass</span> <span class="p">{</span>
<span class="p">...</span>
<span class="p">};</span>
</pre></div>
</div>
</div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Brief-description-(nicer-summary-style)">Brief description (nicer summary style)<a class="anchor-link" href="#Brief-description-(nicer-summary-style)">&#182;</a></h2><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">SuperCoolClass</span> <span class="p">{</span>
<span class="cm">/** \brief This is a simple positions accessor</span>
<span class="cm"> * This accessor gets the position</span>
<span class="cm"> */</span>
<span class="n">Vector</span> <span class="o">&amp;</span> <span class="n">getPosition</span><span class="p">();</span>
<span class="p">};</span>
</pre></div>
<ul>
<li>You can provide the brief only </li>
</ul>
<div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">SuperCoolClass</span> <span class="p">{</span>
<span class="c1">/// This is a simple positions accessor</span>
<span class="n">Vector</span> <span class="o">&amp;</span> <span class="n">getPosition</span><span class="p">();</span>
<span class="p">};</span>
</pre></div>
</div>
</div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Documenting-arguments">Documenting arguments<a class="anchor-link" href="#Documenting-arguments">&#182;</a></h2><div class="highlight"><pre><span></span><span class="cm">/*!</span>
<span class="cm"> \param arg1 an integer argument.</span>
<span class="cm"> \param arg2 a double argument.</span>
<span class="cm"> \return The integer result</span>
<span class="cm"> foo function description</span>
<span class="cm">*/</span>
<span class="kt">int</span> <span class="nf">foo</span><span class="p">(</span><span class="kt">int</span> <span class="n">arg1</span><span class="p">,</span> <span class="kt">double</span> <span class="n">arg2</span><span class="p">);</span>
</pre></div>
</div>
</div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Generating-the-documentation">Generating the documentation<a class="anchor-link" href="#Generating-the-documentation">&#182;</a></h2><ul>
<li><p>Configuring Doxygen produces a 'Doxygen' file.</p>
<p>The easiest way $\Longrightarrow$ using <em>doxywizard</em> application.</p>
</li>
</ul>
<ul>
<li>Launch doxygen to generate a html webpage:</li>
</ul>
<div class="highlight"><pre><span></span>doxygen Doxygen
</pre></div>
</div>
</div></div>
</section></section><section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h1 id="Python-docstring"><a href="http://epydoc.sourceforge.net/docstrings.html">Python docstring</a><a class="anchor-link" href="#Python-docstring">&#182;</a></h1><ul>
<li><a href="https://thomas-cokelaer.info/tutorials/sphinx/docstring_python.html">Cheat sheet</a> </li>
</ul>
</div>
</div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Block-annotation">Block annotation<a class="anchor-link" href="#Block-annotation">&#182;</a></h2><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">SuperCoolClass</span><span class="p">:</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> This is my annotation comments</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">def</span> <span class="nf">myMethod</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> This is a method of the class</span>
<span class="sd"> &quot;&quot;&quot;</span>
</pre></div>
<p>Introspection during program run:</p>
<div class="highlight"><pre><span></span><span class="n">help</span><span class="p">(</span><span class="n">SuperCoolClass</span><span class="p">)</span>
</pre></div>
</div>
</div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Pydoc"><a href="https://docs.python.org/3.6/library/pydoc.html">Pydoc</a><a class="anchor-link" href="#Pydoc">&#182;</a></h2><p>A simple documentation can be generated with</p>
<div class="highlight"><pre><span></span>&gt; pydoc module_name
</pre></div>
</div>
</div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h1 id="Sphinx"><a href="http://www.sphinx-doc.org/en/master/">Sphinx</a><a class="anchor-link" href="#Sphinx">&#182;</a></h1><ul>
<li>Installation: <div class="highlight"><pre><span></span>&gt; sudo apt install python3-sphinx
</pre></div>
</li>
<li><p>Configuring Sphinx produces a 'conf.py' and 'index.rst' files.</p>
<ul>
<li>The easiest way $\Longrightarrow$ using <em>sphinx-quickstart</em> and <em>sphinx-apidoc</em> applications</li>
</ul>
</li>
<li><p>Launch sphinx to generate a html webpage:</p>
</li>
</ul>
<div class="highlight"><pre><span></span>sphinx-build src dest
</pre></div>
<ul>
<li>Useful tutorials: <a href="http://www.sphinx-doc.org/en/master/usage/quickstart.html">sphinx-quickstart</a> and <a href="https://codeandchaos.wordpress.com/2012/07/30/sphinx-autodoc-tutorial-for-dummies/">sphinx-autodoc-tutorial-for-dummies</a></li>
</ul>
</div>
</div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">:param a: description</span>
<span class="sd">:param b: description</span>
<span class="sd">:type a: type description</span>
<span class="sd">:type b: type description</span>
<span class="sd">:return: return description</span>
<span class="sd">:rtype: the return type description</span>
<span class="sd">.. seealso:: blabla</span>
<span class="sd">.. warnings also:: blabla</span>
<span class="sd">.. note:: blabla</span>
<span class="sd">.. todo:: blabla</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="n">DO_SOMETHING</span>
</pre></div>
</div>
</div></div>
</section></section><section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h1 id="Test-Suites"><center>Test Suites</center><a class="anchor-link" href="#Test-Suites">&#182;</a></h1>
</div>
</div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h1 id="Google-Unit-Test-for-C++-testing"><a href="https://github.com/google/googletest">Google Unit Test</a> for C++ testing<a class="anchor-link" href="#Google-Unit-Test-for-C++-testing">&#182;</a></h1>
</div>
</div><div class="fragment" style="width: 100%;float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<ul>
<li><a href="https://en.wikipedia.org/wiki/XUnit">xUnit</a> is the collective name for several unit testing frameworks</li>
<li><a href="https://github.com/google/googletest/blob/master/googletest/docs/primer.md">Google Test primer</a> $\Rightarrow$ Guidelines/Tutorial</li>
<li><a href="https://github.com/google/googletest/blob/master/googletest/docs/advanced.md">Advanced Google test topics</a></li>
<li><a href="https://www.bogotobogo.com/cplusplus/google_unit_test_gtest.php">Another Google Test Tutorial</a></li>
<li>Installation:<div class="highlight"><pre><span></span>&gt; sudo apt install libgtest-dev
</pre></div>
</li>
</ul>
</div>
</div></div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h1 id="Test-a-square-root-function">Test a square root function<a class="anchor-link" href="#Test-a-square-root-function">&#182;</a></h1>
</div>
</div><div class="full" style="width: 100%; float: left">
<div class="cell border-box-sizing code_cell rendered">
<div class="output_area">
<div class="output_html rendered_html output_subarea output_execute_result">
<style>
.hll { background-color: #ffffcc }
.c { color: #408080; font-style: italic } /* Comment */
.err { border: 1px solid #FF0000 } /* Error */
.k { color: #008000; font-weight: bold } /* Keyword */
.o { color: #666666 } /* Operator */
.ch { color: #408080; font-style: italic } /* Comment.Hashbang */
.cm { color: #408080; font-style: italic } /* Comment.Multiline */
.cp { color: #BC7A00 } /* Comment.Preproc */
.cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */
.c1 { color: #408080; font-style: italic } /* Comment.Single */
.cs { color: #408080; font-style: italic } /* Comment.Special */
.gd { color: #A00000 } /* Generic.Deleted */
.ge { font-style: italic } /* Generic.Emph */
.gr { color: #FF0000 } /* Generic.Error */
.gh { color: #000080; font-weight: bold } /* Generic.Heading */
.gi { color: #00A000 } /* Generic.Inserted */
.go { color: #888888 } /* Generic.Output */
.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.gs { font-weight: bold } /* Generic.Strong */
.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.gt { color: #0044DD } /* Generic.Traceback */
.kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.kp { color: #008000 } /* Keyword.Pseudo */
.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.kt { color: #B00040 } /* Keyword.Type */
.m { color: #666666 } /* Literal.Number */
.s { color: #BA2121 } /* Literal.String */
.na { color: #7D9029 } /* Name.Attribute */
.nb { color: #008000 } /* Name.Builtin */
.nc { color: #0000FF; font-weight: bold } /* Name.Class */
.no { color: #880000 } /* Name.Constant */
.nd { color: #AA22FF } /* Name.Decorator */
.ni { color: #999999; font-weight: bold } /* Name.Entity */
.ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.nf { color: #0000FF } /* Name.Function */
.nl { color: #A0A000 } /* Name.Label */
.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.nt { color: #008000; font-weight: bold } /* Name.Tag */
.nv { color: #19177C } /* Name.Variable */
.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.w { color: #bbbbbb } /* Text.Whitespace */
.mb { color: #666666 } /* Literal.Number.Bin */
.mf { color: #666666 } /* Literal.Number.Float */
.mh { color: #666666 } /* Literal.Number.Hex */
.mi { color: #666666 } /* Literal.Number.Integer */
.mo { color: #666666 } /* Literal.Number.Oct */
.sa { color: #BA2121 } /* Literal.String.Affix */
.sb { color: #BA2121 } /* Literal.String.Backtick */
.sc { color: #BA2121 } /* Literal.String.Char */
.dl { color: #BA2121 } /* Literal.String.Delimiter */
.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.s2 { color: #BA2121 } /* Literal.String.Double */
.se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.sh { color: #BA2121 } /* Literal.String.Heredoc */
.si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.sx { color: #008000 } /* Literal.String.Other */
.sr { color: #BB6688 } /* Literal.String.Regex */
.s1 { color: #BA2121 } /* Literal.String.Single */
.ss { color: #19177C } /* Literal.String.Symbol */
.bp { color: #008000 } /* Name.Builtin.Pseudo */
.fm { color: #0000FF } /* Name.Function.Magic */
.vc { color: #19177C } /* Name.Variable.Class */
.vg { color: #19177C } /* Name.Variable.Global */
.vi { color: #19177C } /* Name.Variable.Instance */
.vm { color: #19177C } /* Name.Variable.Magic */
.il { color: #666666 } /* Literal.Number.Integer.Long */
</style>
<div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf">&lt;cmath&gt;</span><span class="cp"></span>
<span class="cp">#include</span> <span class="cpf">&lt;exception&gt;</span><span class="cp"></span>
<span class="k">struct</span> <span class="nl">NegativeException</span> <span class="p">:</span> <span class="k">public</span> <span class="n">std</span><span class="o">::</span><span class="n">exception</span> <span class="p">{};</span>
<span class="kt">double</span> <span class="nf">mysqrt</span><span class="p">(</span><span class="kt">double</span> <span class="n">x</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="n">x</span> <span class="o">&lt;</span> <span class="mf">0.</span><span class="p">)</span>
<span class="k">throw</span> <span class="n">NegativeException</span><span class="p">();</span>
<span class="k">return</span> <span class="n">std</span><span class="o">::</span><span class="n">sqrt</span><span class="p">(</span><span class="n">x</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
</div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Equality-test">Equality test<a class="anchor-link" href="#Equality-test">&#182;</a></h2>
</div>
</div><div class="full" style="width: 100%; float: left">
<div class="cell border-box-sizing code_cell rendered">
<div class="output_area">
<div class="output_html rendered_html output_subarea output_execute_result">
<style>
.hll { background-color: #ffffcc }
.c { color: #408080; font-style: italic } /* Comment */
.err { border: 1px solid #FF0000 } /* Error */
.k { color: #008000; font-weight: bold } /* Keyword */
.o { color: #666666 } /* Operator */
.ch { color: #408080; font-style: italic } /* Comment.Hashbang */
.cm { color: #408080; font-style: italic } /* Comment.Multiline */
.cp { color: #BC7A00 } /* Comment.Preproc */
.cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */
.c1 { color: #408080; font-style: italic } /* Comment.Single */
.cs { color: #408080; font-style: italic } /* Comment.Special */
.gd { color: #A00000 } /* Generic.Deleted */
.ge { font-style: italic } /* Generic.Emph */
.gr { color: #FF0000 } /* Generic.Error */
.gh { color: #000080; font-weight: bold } /* Generic.Heading */
.gi { color: #00A000 } /* Generic.Inserted */
.go { color: #888888 } /* Generic.Output */
.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.gs { font-weight: bold } /* Generic.Strong */
.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.gt { color: #0044DD } /* Generic.Traceback */
.kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.kp { color: #008000 } /* Keyword.Pseudo */
.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.kt { color: #B00040 } /* Keyword.Type */
.m { color: #666666 } /* Literal.Number */
.s { color: #BA2121 } /* Literal.String */
.na { color: #7D9029 } /* Name.Attribute */
.nb { color: #008000 } /* Name.Builtin */
.nc { color: #0000FF; font-weight: bold } /* Name.Class */
.no { color: #880000 } /* Name.Constant */
.nd { color: #AA22FF } /* Name.Decorator */
.ni { color: #999999; font-weight: bold } /* Name.Entity */
.ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.nf { color: #0000FF } /* Name.Function */
.nl { color: #A0A000 } /* Name.Label */
.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.nt { color: #008000; font-weight: bold } /* Name.Tag */
.nv { color: #19177C } /* Name.Variable */
.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.w { color: #bbbbbb } /* Text.Whitespace */
.mb { color: #666666 } /* Literal.Number.Bin */
.mf { color: #666666 } /* Literal.Number.Float */
.mh { color: #666666 } /* Literal.Number.Hex */
.mi { color: #666666 } /* Literal.Number.Integer */
.mo { color: #666666 } /* Literal.Number.Oct */
.sa { color: #BA2121 } /* Literal.String.Affix */
.sb { color: #BA2121 } /* Literal.String.Backtick */
.sc { color: #BA2121 } /* Literal.String.Char */
.dl { color: #BA2121 } /* Literal.String.Delimiter */
.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.s2 { color: #BA2121 } /* Literal.String.Double */
.se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.sh { color: #BA2121 } /* Literal.String.Heredoc */
.si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.sx { color: #008000 } /* Literal.String.Other */
.sr { color: #BB6688 } /* Literal.String.Regex */
.s1 { color: #BA2121 } /* Literal.String.Single */
.ss { color: #19177C } /* Literal.String.Symbol */
.bp { color: #008000 } /* Name.Builtin.Pseudo */
.fm { color: #0000FF } /* Name.Function.Magic */
.vc { color: #19177C } /* Name.Variable.Class */
.vg { color: #19177C } /* Name.Variable.Global */
.vi { color: #19177C } /* Name.Variable.Instance */
.vm { color: #19177C } /* Name.Variable.Magic */
.il { color: #666666 } /* Literal.Number.Integer.Long */
</style>
<div class="highlight"><pre><span></span><span class="cp">#include</span> <span class="cpf">&lt;gtest/gtest.h&gt;</span><span class="cp"></span>
<span class="c1">// MACRO function &quot;TEST&quot; from Google Test</span>
<span class="c1">// defines a test and a context</span>
<span class="n">TEST</span><span class="p">(</span><span class="n">MysqrtTest</span><span class="p">,</span> <span class="n">positive_integers</span><span class="p">)</span> <span class="p">{</span>
<span class="n">EXPECT_EQ</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="n">mysqrt</span><span class="p">(</span><span class="mi">4</span><span class="p">));</span>
<span class="n">EXPECT_EQ</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="n">mysqrt</span><span class="p">(</span><span class="mi">16</span><span class="p">));</span>
<span class="n">EXPECT_EQ</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="n">mysqrt</span><span class="p">(</span><span class="mi">9</span><span class="p">));</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
</div><div class="fragment" style="width: 100%;float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<div class="highlight"><pre><span></span>g++ mysqrt_test.cc -o <span class="nb">test</span> -lgtest_main -lgtest -lpthread
./test
</pre></div>
</div>
</div></div><div class="fragment" style="width: 100%;float: left"><div class="full" style="width: 100%; float: left">
<div class="cell border-box-sizing code_cell rendered">
<div class="output_area">
<div class="output_subarea output_stream output_stdout output_text">
<pre>[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from MysqrtTest
[ RUN ] MysqrtTest.positive_integers
[ OK ] MysqrtTest.positive_integers (0 ms)
[----------] 1 test from MysqrtTest (0 ms total)
</pre>
</div>
</div>
</div>
</div></div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Near-equality-test">Near equality test<a class="anchor-link" href="#Near-equality-test">&#182;</a></h2>
</div>
</div><div class="full" style="width: 100%; float: left">
<div class="cell border-box-sizing code_cell rendered">
<div class="output_area">
<div class="output_html rendered_html output_subarea output_execute_result">
<style>
.hll { background-color: #ffffcc }
.c { color: #408080; font-style: italic } /* Comment */
.err { border: 1px solid #FF0000 } /* Error */
.k { color: #008000; font-weight: bold } /* Keyword */
.o { color: #666666 } /* Operator */
.ch { color: #408080; font-style: italic } /* Comment.Hashbang */
.cm { color: #408080; font-style: italic } /* Comment.Multiline */
.cp { color: #BC7A00 } /* Comment.Preproc */
.cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */
.c1 { color: #408080; font-style: italic } /* Comment.Single */
.cs { color: #408080; font-style: italic } /* Comment.Special */
.gd { color: #A00000 } /* Generic.Deleted */
.ge { font-style: italic } /* Generic.Emph */
.gr { color: #FF0000 } /* Generic.Error */
.gh { color: #000080; font-weight: bold } /* Generic.Heading */
.gi { color: #00A000 } /* Generic.Inserted */
.go { color: #888888 } /* Generic.Output */
.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.gs { font-weight: bold } /* Generic.Strong */
.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.gt { color: #0044DD } /* Generic.Traceback */
.kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.kp { color: #008000 } /* Keyword.Pseudo */
.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.kt { color: #B00040 } /* Keyword.Type */
.m { color: #666666 } /* Literal.Number */
.s { color: #BA2121 } /* Literal.String */
.na { color: #7D9029 } /* Name.Attribute */
.nb { color: #008000 } /* Name.Builtin */
.nc { color: #0000FF; font-weight: bold } /* Name.Class */
.no { color: #880000 } /* Name.Constant */
.nd { color: #AA22FF } /* Name.Decorator */
.ni { color: #999999; font-weight: bold } /* Name.Entity */
.ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.nf { color: #0000FF } /* Name.Function */
.nl { color: #A0A000 } /* Name.Label */
.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.nt { color: #008000; font-weight: bold } /* Name.Tag */
.nv { color: #19177C } /* Name.Variable */
.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.w { color: #bbbbbb } /* Text.Whitespace */
.mb { color: #666666 } /* Literal.Number.Bin */
.mf { color: #666666 } /* Literal.Number.Float */
.mh { color: #666666 } /* Literal.Number.Hex */
.mi { color: #666666 } /* Literal.Number.Integer */
.mo { color: #666666 } /* Literal.Number.Oct */
.sa { color: #BA2121 } /* Literal.String.Affix */
.sb { color: #BA2121 } /* Literal.String.Backtick */
.sc { color: #BA2121 } /* Literal.String.Char */
.dl { color: #BA2121 } /* Literal.String.Delimiter */
.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.s2 { color: #BA2121 } /* Literal.String.Double */
.se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.sh { color: #BA2121 } /* Literal.String.Heredoc */
.si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.sx { color: #008000 } /* Literal.String.Other */
.sr { color: #BB6688 } /* Literal.String.Regex */
.s1 { color: #BA2121 } /* Literal.String.Single */
.ss { color: #19177C } /* Literal.String.Symbol */
.bp { color: #008000 } /* Name.Builtin.Pseudo */
.fm { color: #0000FF } /* Name.Function.Magic */
.vc { color: #19177C } /* Name.Variable.Class */
.vg { color: #19177C } /* Name.Variable.Global */
.vi { color: #19177C } /* Name.Variable.Instance */
.vm { color: #19177C } /* Name.Variable.Magic */
.il { color: #666666 } /* Literal.Number.Integer.Long */
</style>
<div class="highlight"><pre><span></span><span class="n">TEST</span><span class="p">(</span><span class="n">MysqrtTest</span><span class="p">,</span> <span class="n">positive_doubles</span><span class="p">)</span> <span class="p">{</span>
<span class="n">ASSERT_NEAR</span><span class="p">(</span><span class="n">std</span><span class="o">::</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">mysqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="mf">1e-15</span><span class="p">);</span>
<span class="n">ASSERT_NEAR</span><span class="p">(</span><span class="n">std</span><span class="o">::</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">mysqrt</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="mf">1e-15</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
</div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Assertion-test">Assertion test<a class="anchor-link" href="#Assertion-test">&#182;</a></h2>
</div>
</div><div class="full" style="width: 100%; float: left">
<div class="cell border-box-sizing code_cell rendered">
<div class="output_area">
<div class="output_html rendered_html output_subarea output_execute_result">
<style>
.hll { background-color: #ffffcc }
.c { color: #408080; font-style: italic } /* Comment */
.err { border: 1px solid #FF0000 } /* Error */
.k { color: #008000; font-weight: bold } /* Keyword */
.o { color: #666666 } /* Operator */
.ch { color: #408080; font-style: italic } /* Comment.Hashbang */
.cm { color: #408080; font-style: italic } /* Comment.Multiline */
.cp { color: #BC7A00 } /* Comment.Preproc */
.cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */
.c1 { color: #408080; font-style: italic } /* Comment.Single */
.cs { color: #408080; font-style: italic } /* Comment.Special */
.gd { color: #A00000 } /* Generic.Deleted */
.ge { font-style: italic } /* Generic.Emph */
.gr { color: #FF0000 } /* Generic.Error */
.gh { color: #000080; font-weight: bold } /* Generic.Heading */
.gi { color: #00A000 } /* Generic.Inserted */
.go { color: #888888 } /* Generic.Output */
.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.gs { font-weight: bold } /* Generic.Strong */
.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.gt { color: #0044DD } /* Generic.Traceback */
.kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.kp { color: #008000 } /* Keyword.Pseudo */
.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.kt { color: #B00040 } /* Keyword.Type */
.m { color: #666666 } /* Literal.Number */
.s { color: #BA2121 } /* Literal.String */
.na { color: #7D9029 } /* Name.Attribute */
.nb { color: #008000 } /* Name.Builtin */
.nc { color: #0000FF; font-weight: bold } /* Name.Class */
.no { color: #880000 } /* Name.Constant */
.nd { color: #AA22FF } /* Name.Decorator */
.ni { color: #999999; font-weight: bold } /* Name.Entity */
.ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.nf { color: #0000FF } /* Name.Function */
.nl { color: #A0A000 } /* Name.Label */
.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.nt { color: #008000; font-weight: bold } /* Name.Tag */
.nv { color: #19177C } /* Name.Variable */
.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.w { color: #bbbbbb } /* Text.Whitespace */
.mb { color: #666666 } /* Literal.Number.Bin */
.mf { color: #666666 } /* Literal.Number.Float */
.mh { color: #666666 } /* Literal.Number.Hex */
.mi { color: #666666 } /* Literal.Number.Integer */
.mo { color: #666666 } /* Literal.Number.Oct */
.sa { color: #BA2121 } /* Literal.String.Affix */
.sb { color: #BA2121 } /* Literal.String.Backtick */
.sc { color: #BA2121 } /* Literal.String.Char */
.dl { color: #BA2121 } /* Literal.String.Delimiter */
.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.s2 { color: #BA2121 } /* Literal.String.Double */
.se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.sh { color: #BA2121 } /* Literal.String.Heredoc */
.si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.sx { color: #008000 } /* Literal.String.Other */
.sr { color: #BB6688 } /* Literal.String.Regex */
.s1 { color: #BA2121 } /* Literal.String.Single */
.ss { color: #19177C } /* Literal.String.Symbol */
.bp { color: #008000 } /* Name.Builtin.Pseudo */
.fm { color: #0000FF } /* Name.Function.Magic */
.vc { color: #19177C } /* Name.Variable.Class */
.vg { color: #19177C } /* Name.Variable.Global */
.vi { color: #19177C } /* Name.Variable.Instance */
.vm { color: #19177C } /* Name.Variable.Magic */
.il { color: #666666 } /* Literal.Number.Integer.Long */
</style>
<div class="highlight"><pre><span></span><span class="n">TEST</span><span class="p">(</span><span class="n">MysqrtTest</span><span class="p">,</span> <span class="n">negative</span><span class="p">)</span> <span class="p">{</span>
<span class="c1">// check that exception is thrown</span>
<span class="n">ASSERT_THROW</span><span class="p">(</span><span class="n">mysqrt</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">),</span> <span class="n">NegativeException</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
</div><div class="full" style="width: 100%; float: left">
<div class="cell border-box-sizing code_cell rendered">
</div>
</div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Fixtures">Fixtures<a class="anchor-link" href="#Fixtures">&#182;</a></h2><ul>
<li>When several test have a common preparation: Fixture classes</li>
<li><em>SetUp</em> and <em>TearDown</em> methods</li>
</ul>
</div>
</div><div class="fragment" style="width: 100%;float: left"><div class="full" style="width: 100%; float: left">
<div class="cell border-box-sizing code_cell rendered">
<div class="output_area">
<div class="output_html rendered_html output_subarea output_execute_result">
<style>
.hll { background-color: #ffffcc }
.c { color: #408080; font-style: italic } /* Comment */
.err { border: 1px solid #FF0000 } /* Error */
.k { color: #008000; font-weight: bold } /* Keyword */
.o { color: #666666 } /* Operator */
.ch { color: #408080; font-style: italic } /* Comment.Hashbang */
.cm { color: #408080; font-style: italic } /* Comment.Multiline */
.cp { color: #BC7A00 } /* Comment.Preproc */
.cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */
.c1 { color: #408080; font-style: italic } /* Comment.Single */
.cs { color: #408080; font-style: italic } /* Comment.Special */
.gd { color: #A00000 } /* Generic.Deleted */
.ge { font-style: italic } /* Generic.Emph */
.gr { color: #FF0000 } /* Generic.Error */
.gh { color: #000080; font-weight: bold } /* Generic.Heading */
.gi { color: #00A000 } /* Generic.Inserted */
.go { color: #888888 } /* Generic.Output */
.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.gs { font-weight: bold } /* Generic.Strong */
.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.gt { color: #0044DD } /* Generic.Traceback */
.kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.kp { color: #008000 } /* Keyword.Pseudo */
.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.kt { color: #B00040 } /* Keyword.Type */
.m { color: #666666 } /* Literal.Number */
.s { color: #BA2121 } /* Literal.String */
.na { color: #7D9029 } /* Name.Attribute */
.nb { color: #008000 } /* Name.Builtin */
.nc { color: #0000FF; font-weight: bold } /* Name.Class */
.no { color: #880000 } /* Name.Constant */
.nd { color: #AA22FF } /* Name.Decorator */
.ni { color: #999999; font-weight: bold } /* Name.Entity */
.ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.nf { color: #0000FF } /* Name.Function */
.nl { color: #A0A000 } /* Name.Label */
.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.nt { color: #008000; font-weight: bold } /* Name.Tag */
.nv { color: #19177C } /* Name.Variable */
.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.w { color: #bbbbbb } /* Text.Whitespace */
.mb { color: #666666 } /* Literal.Number.Bin */
.mf { color: #666666 } /* Literal.Number.Float */
.mh { color: #666666 } /* Literal.Number.Hex */
.mi { color: #666666 } /* Literal.Number.Integer */
.mo { color: #666666 } /* Literal.Number.Oct */
.sa { color: #BA2121 } /* Literal.String.Affix */
.sb { color: #BA2121 } /* Literal.String.Backtick */
.sc { color: #BA2121 } /* Literal.String.Char */
.dl { color: #BA2121 } /* Literal.String.Delimiter */
.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.s2 { color: #BA2121 } /* Literal.String.Double */
.se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.sh { color: #BA2121 } /* Literal.String.Heredoc */
.si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.sx { color: #008000 } /* Literal.String.Other */
.sr { color: #BB6688 } /* Literal.String.Regex */
.s1 { color: #BA2121 } /* Literal.String.Single */
.ss { color: #19177C } /* Literal.String.Symbol */
.bp { color: #008000 } /* Name.Builtin.Pseudo */
.fm { color: #0000FF } /* Name.Function.Magic */
.vc { color: #19177C } /* Name.Variable.Class */
.vg { color: #19177C } /* Name.Variable.Global */
.vi { color: #19177C } /* Name.Variable.Instance */
.vm { color: #19177C } /* Name.Variable.Magic */
.il { color: #666666 } /* Literal.Number.Integer.Long */
</style>
<div class="highlight"><pre><span></span><span class="k">struct</span> <span class="n">Particle</span> <span class="p">{</span>
<span class="kt">double</span> <span class="n">position</span><span class="p">[</span><span class="mi">3</span><span class="p">];</span>
<span class="kt">double</span> <span class="n">velocity</span><span class="p">[</span><span class="mi">3</span><span class="p">];</span>
<span class="kt">double</span> <span class="n">force</span><span class="p">[</span><span class="mi">3</span><span class="p">];</span>
<span class="p">};</span>
<span class="k">struct</span> <span class="n">System</span> <span class="p">{</span>
<span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">Particle</span><span class="o">&gt;</span> <span class="n">particles</span><span class="p">;</span>
<span class="p">};</span>
</pre></div>
</div>
</div>
</div>
</div></div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Fixtures">Fixtures<a class="anchor-link" href="#Fixtures">&#182;</a></h2><ul>
<li>When several test have a common preparation: Fixture classes</li>
<li><em>SetUp</em> and <em>TearDown</em> methods</li>
</ul>
</div>
</div><div class="full" style="width: 100%; float: left">
<div class="cell border-box-sizing code_cell rendered">
<div class="output_area">
<div class="output_html rendered_html output_subarea output_execute_result">
<style>
.hll { background-color: #ffffcc }
.c { color: #408080; font-style: italic } /* Comment */
.err { border: 1px solid #FF0000 } /* Error */
.k { color: #008000; font-weight: bold } /* Keyword */
.o { color: #666666 } /* Operator */
.ch { color: #408080; font-style: italic } /* Comment.Hashbang */
.cm { color: #408080; font-style: italic } /* Comment.Multiline */
.cp { color: #BC7A00 } /* Comment.Preproc */
.cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */
.c1 { color: #408080; font-style: italic } /* Comment.Single */
.cs { color: #408080; font-style: italic } /* Comment.Special */
.gd { color: #A00000 } /* Generic.Deleted */
.ge { font-style: italic } /* Generic.Emph */
.gr { color: #FF0000 } /* Generic.Error */
.gh { color: #000080; font-weight: bold } /* Generic.Heading */
.gi { color: #00A000 } /* Generic.Inserted */
.go { color: #888888 } /* Generic.Output */
.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.gs { font-weight: bold } /* Generic.Strong */
.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.gt { color: #0044DD } /* Generic.Traceback */
.kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.kp { color: #008000 } /* Keyword.Pseudo */
.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.kt { color: #B00040 } /* Keyword.Type */
.m { color: #666666 } /* Literal.Number */
.s { color: #BA2121 } /* Literal.String */
.na { color: #7D9029 } /* Name.Attribute */
.nb { color: #008000 } /* Name.Builtin */
.nc { color: #0000FF; font-weight: bold } /* Name.Class */
.no { color: #880000 } /* Name.Constant */
.nd { color: #AA22FF } /* Name.Decorator */
.ni { color: #999999; font-weight: bold } /* Name.Entity */
.ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.nf { color: #0000FF } /* Name.Function */
.nl { color: #A0A000 } /* Name.Label */
.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.nt { color: #008000; font-weight: bold } /* Name.Tag */
.nv { color: #19177C } /* Name.Variable */
.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.w { color: #bbbbbb } /* Text.Whitespace */
.mb { color: #666666 } /* Literal.Number.Bin */
.mf { color: #666666 } /* Literal.Number.Float */
.mh { color: #666666 } /* Literal.Number.Hex */
.mi { color: #666666 } /* Literal.Number.Integer */
.mo { color: #666666 } /* Literal.Number.Oct */
.sa { color: #BA2121 } /* Literal.String.Affix */
.sb { color: #BA2121 } /* Literal.String.Backtick */
.sc { color: #BA2121 } /* Literal.String.Char */
.dl { color: #BA2121 } /* Literal.String.Delimiter */
.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.s2 { color: #BA2121 } /* Literal.String.Double */
.se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.sh { color: #BA2121 } /* Literal.String.Heredoc */
.si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.sx { color: #008000 } /* Literal.String.Other */
.sr { color: #BB6688 } /* Literal.String.Regex */
.s1 { color: #BA2121 } /* Literal.String.Single */
.ss { color: #19177C } /* Literal.String.Symbol */
.bp { color: #008000 } /* Name.Builtin.Pseudo */
.fm { color: #0000FF } /* Name.Function.Magic */
.vc { color: #19177C } /* Name.Variable.Class */
.vg { color: #19177C } /* Name.Variable.Global */
.vi { color: #19177C } /* Name.Variable.Instance */
.vm { color: #19177C } /* Name.Variable.Magic */
.il { color: #666666 } /* Literal.Number.Integer.Long */
</style>
<div class="highlight"><pre><span></span>// Fixture class
class SystemTest : public ::testing::Test {
protected:
void <span style="color:red;font-size:150%">SetUp</span>() override {
// push 10 particles
system.particles.resize(10);
}
void <span style="color:red;font-size:150%">TearDown</span>() override {
// clear particles
system.particles.clear();
}
System system;
};
</pre></div>
</div>
</div>
</div>
</div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Fixtures">Fixtures<a class="anchor-link" href="#Fixtures">&#182;</a></h2><ul>
<li>When several test have a common preparation: Fixture classes</li>
<li><em>SetUp</em> and <em>TearDown</em> methods</li>
</ul>
</div>
</div><div class="full" style="width: 100%; float: left">
<div class="cell border-box-sizing code_cell rendered">
<div class="output_area">
<div class="output_html rendered_html output_subarea output_execute_result">
<style>
.hll { background-color: #ffffcc }
.c { color: #408080; font-style: italic } /* Comment */
.err { border: 1px solid #FF0000 } /* Error */
.k { color: #008000; font-weight: bold } /* Keyword */
.o { color: #666666 } /* Operator */
.ch { color: #408080; font-style: italic } /* Comment.Hashbang */
.cm { color: #408080; font-style: italic } /* Comment.Multiline */
.cp { color: #BC7A00 } /* Comment.Preproc */
.cpf { color: #408080; font-style: italic } /* Comment.PreprocFile */
.c1 { color: #408080; font-style: italic } /* Comment.Single */
.cs { color: #408080; font-style: italic } /* Comment.Special */
.gd { color: #A00000 } /* Generic.Deleted */
.ge { font-style: italic } /* Generic.Emph */
.gr { color: #FF0000 } /* Generic.Error */
.gh { color: #000080; font-weight: bold } /* Generic.Heading */
.gi { color: #00A000 } /* Generic.Inserted */
.go { color: #888888 } /* Generic.Output */
.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.gs { font-weight: bold } /* Generic.Strong */
.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.gt { color: #0044DD } /* Generic.Traceback */
.kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.kp { color: #008000 } /* Keyword.Pseudo */
.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.kt { color: #B00040 } /* Keyword.Type */
.m { color: #666666 } /* Literal.Number */
.s { color: #BA2121 } /* Literal.String */
.na { color: #7D9029 } /* Name.Attribute */
.nb { color: #008000 } /* Name.Builtin */
.nc { color: #0000FF; font-weight: bold } /* Name.Class */
.no { color: #880000 } /* Name.Constant */
.nd { color: #AA22FF } /* Name.Decorator */
.ni { color: #999999; font-weight: bold } /* Name.Entity */
.ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.nf { color: #0000FF } /* Name.Function */
.nl { color: #A0A000 } /* Name.Label */
.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.nt { color: #008000; font-weight: bold } /* Name.Tag */
.nv { color: #19177C } /* Name.Variable */
.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.w { color: #bbbbbb } /* Text.Whitespace */
.mb { color: #666666 } /* Literal.Number.Bin */
.mf { color: #666666 } /* Literal.Number.Float */
.mh { color: #666666 } /* Literal.Number.Hex */
.mi { color: #666666 } /* Literal.Number.Integer */
.mo { color: #666666 } /* Literal.Number.Oct */
.sa { color: #BA2121 } /* Literal.String.Affix */
.sb { color: #BA2121 } /* Literal.String.Backtick */
.sc { color: #BA2121 } /* Literal.String.Char */
.dl { color: #BA2121 } /* Literal.String.Delimiter */
.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.s2 { color: #BA2121 } /* Literal.String.Double */
.se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
.sh { color: #BA2121 } /* Literal.String.Heredoc */
.si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
.sx { color: #008000 } /* Literal.String.Other */
.sr { color: #BB6688 } /* Literal.String.Regex */
.s1 { color: #BA2121 } /* Literal.String.Single */
.ss { color: #19177C } /* Literal.String.Symbol */
.bp { color: #008000 } /* Name.Builtin.Pseudo */
.fm { color: #0000FF } /* Name.Function.Magic */
.vc { color: #19177C } /* Name.Variable.Class */
.vg { color: #19177C } /* Name.Variable.Global */
.vi { color: #19177C } /* Name.Variable.Instance */
.vm { color: #19177C } /* Name.Variable.Magic */
.il { color: #666666 } /* Literal.Number.Integer.Long */
</style>
<div class="highlight"><pre><span></span>
// Fixture test
<span style="color:red;font-size:150%">TEST_F</span>(SystemTest, IsNotEmpty) {
// check the size of container
EXPECT_EQ(system.particles.size(), 10);
}
</pre></div>
</div>
</div>
</div>
</div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h1 id="Pytest"><a href="https://docs.pytest.org/en/latest/">Pytest</a><a class="anchor-link" href="#Pytest">&#182;</a></h1><ul>
<li>Installation: <div class="highlight"><pre><span></span>&gt; sudo apt install python3-pytest
</pre></div>
</li>
<li><a href="https://docs.pytest.org/en/latest/contents.html#toc">Documentation</a></li>
</ul>
</div>
</div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Testing-the-(similar)-mysqrt-function">Testing the (similar) mysqrt function<a class="anchor-link" href="#Testing-the-(similar)-mysqrt-function">&#182;</a></h2><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">mysqrt</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
<span class="k">if</span> <span class="p">(</span><span class="n">x</span> <span class="o">&lt;</span> <span class="mf">0.</span><span class="p">):</span>
<span class="k">raise</span> <span class="n">NegativeException</span><span class="p">();</span>
<span class="k">return</span> <span class="n">math</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">x</span><span class="p">);</span>
<span class="k">def</span> <span class="nf">test_mysqrt_int</span><span class="p">():</span>
<span class="k">assert</span> <span class="n">mysqrt</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span>
<span class="k">def</span> <span class="nf">test_mysqrt_double</span><span class="p">():</span>
<span class="k">assert</span> <span class="n">mysqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="o">==</span> <span class="n">math</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">test_mysqrt_negative</span><span class="p">():</span>
<span class="k">with</span> <span class="n">pytest</span><span class="o">.</span><span class="n">raises</span><span class="p">(</span><span class="n">NegativeException</span><span class="p">):</span>
<span class="n">mysqrt</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
</div></div>
</section><section>
<div class="slide" style="float: left"><div class="full" style="width: 100%; float: left">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Pytest-fixtures">Pytest fixtures<a class="anchor-link" href="#Pytest-fixtures">&#182;</a></h2><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">pytest</span>
<span class="nd">@pytest.fixture</span>
<span class="k">def</span> <span class="nf">SystemTest</span><span class="p">():</span>
<span class="c1"># SetUp</span>
<span class="n">System</span><span class="o">.</span><span class="n">particles</span> <span class="o">=</span> <span class="p">[</span><span class="n">Particle</span><span class="p">()</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">10</span><span class="p">)]</span>
<span class="k">yield</span>
<span class="c1"># TearDown</span>
<span class="n">System</span><span class="o">.</span><span class="n">particles</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">def</span> <span class="nf">test_is_not_empty</span><span class="p">(</span><span class="n">SystemTest</span><span class="p">):</span>
<span class="k">assert</span> <span class="nb">len</span><span class="p">(</span><span class="n">system</span><span class="o">.</span><span class="n">particles</span><span class="p">)</span> <span class="o">==</span> <span class="mi">10</span>
</pre></div>
</div>
</div></div>
</section></section>
</div>
</div>
<!-- loads reveal -->
<script>
require(
{
// it makes sense to wait a little bit when you are loading
// reveal from a cdn in a slow connection environment
waitSeconds: 1
},
[
"reveal.js/lib/js/head.min.js",
"reveal.js/js/reveal.js"
],
function(head, Reveal){
Reveal.initialize({
//width: '1200px',
//height: '100%'
// margins: 0.1,
controls: true,
progress: true,
history: true,
transition: 'fade',
margin: 0.02,
progress: true,
slideNumber: true,
// Optional libraries used to extend on reveal.js plugins
dependencies: [
{ src: 'reveal.js/lib/js/classList.js',
condition: function() { return !document.body.classList; }
},
{ src: 'reveal.js/plugin/markdown/marked.js',
condition: function() { return !!document.querySelector( '[data-markdown]' ); }
},
{ src: 'reveal.js/plugin/markdown/markdown.js',
condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'reveal.js/plugin/highlight/highlight.js',
async: true, callback: function() { hljs.initHighlightingOnLoad(); }
},
{ src: 'reveal.js/plugin/zoom-js/zoom.js', async: true },
{ src: 'reveal.js/plugin/notes/notes.js',
async: true, condition: function() { return !!document.body.classList; }
}]});
var update = function(event){
if(MathJax.Hub.getAllJax(Reveal.getCurrentSlide())){
MathJax.Hub.Rerender(Reveal.getCurrentSlide());
}
};
Reveal.addEventListener('slidechanged', update);
}
);
$(document).ready(function(){
//$(".cell").css("width","90%");
//$(".cell").css("margin","0 auto");
//$(".output_area").css("text-align","center");
//$(".output_png").css("margin","0 auto");
//$("img").css("margin","0 auto");
//$(".output_html").css("margin", "0 auto");
//$(".output_latex").css("margin", "0 auto");
//$(".output_subarea").css("flex", "None");
$( "markdown" ).each(function( index ) {
$( this ).html(Markdown($( this ).text()));
});
})
</script>
</body>
</html>

Event Timeline