<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <link rel="Start" href="index.html"> <link rel="previous" href="OUnit.html"> <link rel="Up" href="index.html"> <link title="Index of types" rel=Appendix href="index_types.html"> <link title="Index of values" rel=Appendix href="index_values.html"> <link title="Index of modules" rel=Appendix href="index_modules.html"> <link title="Index of module types" rel=Appendix href="index_module_types.html"> <link title="OUnit" rel="Chapter" href="OUnit.html"> <link title="OUnitDiff" rel="Chapter" href="OUnitDiff.html"><link title="Signatures" rel="Section" href="#2_Signatures"> <link title="Implementations" rel="Section" href="#2_Implementations"> <title>OUnit user guide : OUnitDiff</title> </head> <body> <div class="navbar"><a class="pre" href="OUnit.html" title="OUnit">Previous</a> <a class="up" href="index.html" title="Index">Up</a> </div> <h1>Module <a href="type_OUnitDiff.html">OUnitDiff</a></h1> <pre><span class="keyword">module</span> OUnitDiff: <code class="code"><span class="keyword">sig</span></code> <a href="OUnitDiff.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info"> Unit tests for collection of elements <p> This module allows to define a more precise way to display differences between collection of elements. When collection differ, the tester is interested by what are the missing/extra elements. This module provides a <code class="code">diff</code> operation to spot the difference quickly between two sets of elements. <p> Example: <pre class="codepre"><code class="code"><span class="keyword">open</span> <span class="constructor">OUnit</span>;;<br> <br> <span class="keyword">module</span> <span class="constructor">EInt</span> = <br> <span class="keyword">struct</span> <br> <span class="keyword">type</span> t = int<br> <span class="keyword">let</span> compare = ( - )<br> <span class="keyword">let</span> pp_print = <span class="constructor">Format</span>.pp_print_int<br> <span class="keyword">let</span> pp_print_sep = <span class="constructor">OUnitDiff</span>.comma_separator<br> <span class="keyword">end</span><br> <br> <span class="keyword">module</span> <span class="constructor">ListInt</span> = <span class="constructor">OUnitDiff</span>.<span class="constructor">ListSimpleMake</span>(<span class="constructor">EInt</span>);;<br> <br> <span class="keyword">let</span> test_diff () = <br> <span class="constructor">ListInt</span>.assert_equal<br> [1; 2; 3; 4; 5]<br> [1; 2; 5; 4]<br> ;;<br> <br> <span class="keyword">let</span> _ = <br> run_test_tt_main (<span class="string">"test_diff"</span> >:: test_diff)<br> ;;<br> </code></pre> <p> when run this test outputs: <pre class="codepre"><code class="code"><span class="constructor">OUnit</span>: expected: 1, 2, 3, 4, 5 but got: 1, 2, 5, 4<br> differences: element number 2 differ (3 <> 5)<br> </code></pre><br> <b>Author(s):</b> Sylvain Le Gall<br> <b>Since</b> 1.1.0<br> </div> <hr width="100%"> <br> <h2 id="2_Signatures">Signatures</h2><br> <pre><span class="keyword">module type</span> <a href="OUnitDiff.DIFF_ELEMENT.html">DIFF_ELEMENT</a> = <code class="code"><span class="keyword">sig</span></code> <a href="OUnitDiff.DIFF_ELEMENT.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info"> Definition of an element </div> <pre><span class="keyword">module type</span> <a href="OUnitDiff.S.html">S</a> = <code class="code"><span class="keyword">sig</span></code> <a href="OUnitDiff.S.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info"> Definition of standard operations </div> <br> <h2 id="2_Implementations">Implementations</h2><br> <pre><span class="keyword">module</span> <a href="OUnitDiff.SetMake.html">SetMake</a>: <div class="sig_block"><code class="code"><span class="keyword">functor</span> (</code><code class="code"><span class="constructor">D</span></code><code class="code"> : </code><code class="type"><a href="OUnitDiff.DIFF_ELEMENT.html">DIFF_ELEMENT</a></code><code class="code">) <span class="keywordsign">-></span> </code><code class="type"><a href="OUnitDiff.S.html">S</a></code><code class="type"> with type e = D.t</code></div></pre><div class="info"> Collection of elements based on a Set, elements order doesn't matter </div> <pre><span class="keyword">module</span> <a href="OUnitDiff.ListSimpleMake.html">ListSimpleMake</a>: <div class="sig_block"><code class="code"><span class="keyword">functor</span> (</code><code class="code"><span class="constructor">D</span></code><code class="code"> : </code><code class="type"><a href="OUnitDiff.DIFF_ELEMENT.html">DIFF_ELEMENT</a></code><code class="code">) <span class="keywordsign">-></span> </code><code class="type"><a href="OUnitDiff.S.html">S</a></code><code class="type"> with type e = D.t and type t = D.t list</code></div></pre><div class="info"> Collection of elements based on a List, order matters but difference display is very simple. </div> <pre><span id="VALpp_comma_separator"><span class="keyword">val</span> pp_comma_separator</span> : <code class="type">Format.formatter -> unit -> unit</code></pre></body></html>