Boost C++ Libraries: Ticket #11625: BOOST_TEST( ..., per_element() ) erroneously requires collections are comparable https://svn.boost.org/trac10/ticket/11625 <p> Thanks for the new BOOST_TEST() and per_element() tools, which look very useful. </p> <p> Unfortunately, I'm having trouble with comparing collections that aren't themselves comparable but have comparable elements. </p> <p> As I understand <a href="http://www.boost.org/libs/test/doc/html/boost_test/testing_tools/extended_comparison/collections.html#boost_test.testing_tools.extended_comparison.collections.requirements">the requirements documentation</a> for the BOOST_TEST / per_element() tools, they should only require that the two collections' <em>elements</em> are comparable, not necessarily the two collections themselves. I think this approach makes a lot of sense. </p> <p> However, when I try to compile the following under either <code>g++ -std=c++11</code> or <code>clang -std=c++11 -stdlib=libc++</code>, the compilers complain that collections aren't comparable : </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#define BOOST_TEST_MODULE comp_by_elem_mod</span> <span class="cp">#include</span> <span class="cpf">&lt;boost/test/included/unit_test.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;iterator&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;vector&gt;</span><span class="cp"></span> <span class="k">struct</span> <span class="n">my_class</span> <span class="k">final</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="kt">int</span><span class="o">&gt;</span> <span class="n">the_ints</span> <span class="o">=</span> <span class="p">{</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span> <span class="p">};</span> <span class="k">using</span> <span class="n">const_iterator</span> <span class="o">=</span> <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;::</span><span class="n">const_iterator</span><span class="p">;</span> <span class="n">const_iterator</span> <span class="nf">begin</span><span class="p">()</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="n">std</span><span class="o">::</span><span class="n">begin</span><span class="p">(</span> <span class="n">the_ints</span> <span class="p">);</span> <span class="p">}</span> <span class="n">const_iterator</span> <span class="nf">end</span><span class="p">()</span> <span class="k">const</span> <span class="p">{</span> <span class="k">return</span> <span class="n">std</span><span class="o">::</span><span class="n">end</span><span class="p">(</span> <span class="n">the_ints</span> <span class="p">);</span> <span class="p">}</span> <span class="p">};</span> <span class="n">BOOST_AUTO_TEST_CASE</span><span class="p">(</span> <span class="n">comp_by_elem</span> <span class="p">)</span> <span class="p">{</span> <span class="k">const</span> <span class="n">my_class</span> <span class="n">a</span><span class="p">{};</span> <span class="k">const</span> <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span> <span class="n">b</span> <span class="o">=</span> <span class="p">{</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span> <span class="p">};</span> <span class="n">BOOST_TEST</span><span class="p">(</span> <span class="n">a</span> <span class="o">==</span> <span class="n">b</span><span class="p">,</span> <span class="o">::</span><span class="n">boost</span><span class="o">::</span><span class="n">test_tools</span><span class="o">::</span><span class="n">per_element</span><span class="p">()</span> <span class="p">);</span> <span class="p">}</span> </pre></div></div><p> I'll attach compiler errors. </p> <p> Many thanks. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11625 Trac 1.4.3 Tony Lewis <tonyelewis@…> Mon, 07 Sep 2015 10:50:29 GMT attachment set https://svn.boost.org/trac10/ticket/11625 https://svn.boost.org/trac10/ticket/11625 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">clang_compiler_errors.err</span> </li> </ul> <p> clang </p> Ticket Tony Lewis <tonyelewis@…> Mon, 07 Sep 2015 10:50:51 GMT attachment set https://svn.boost.org/trac10/ticket/11625 https://svn.boost.org/trac10/ticket/11625 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">gcc_compiler_errors.err</span> </li> </ul> <p> g++ compilation errors </p> Ticket Tony Lewis <tonyelewis@…> Mon, 07 Sep 2015 10:51:56 GMT component changed; owner set https://svn.boost.org/trac10/ticket/11625#comment:1 https://svn.boost.org/trac10/ticket/11625#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Gennadiy Rozental</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">test</span> </li> </ul> Ticket Raffi Enficiaud Mon, 28 Sep 2015 08:34:43 GMT owner, status changed https://svn.boost.org/trac10/ticket/11625#comment:2 https://svn.boost.org/trac10/ticket/11625#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Gennadiy Rozental</span> to <span class="trac-author">Raffi Enficiaud</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Fixed in develop, assigning to keep track. </p> Ticket Raffi Enficiaud Mon, 28 Sep 2015 08:34:57 GMT version changed https://svn.boost.org/trac10/ticket/11625#comment:3 https://svn.boost.org/trac10/ticket/11625#comment:3 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.57.0</span> → <span class="trac-field-new">Boost 1.59.0</span> </li> </ul> Ticket Raffi Enficiaud Tue, 27 Oct 2015 12:50:45 GMT milestone changed https://svn.boost.org/trac10/ticket/11625#comment:4 https://svn.boost.org/trac10/ticket/11625#comment:4 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.60.0</span> </li> </ul> Ticket Raffi Enficiaud Mon, 02 Nov 2015 10:09:07 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11625#comment:5 https://svn.boost.org/trac10/ticket/11625#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> merged to master </p> Ticket Tony Lewis <tonyelewis@…> Thu, 24 Dec 2015 17:03:49 GMT status, version changed; resolution deleted https://svn.boost.org/trac10/ticket/11625#comment:6 https://svn.boost.org/trac10/ticket/11625#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.59.0</span> → <span class="trac-field-new">Boost 1.60.0</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> I'm still seeing this problem in Boost 1.60.0. Is that expected? </p> Ticket Raffi Enficiaud Sat, 09 Jan 2016 18:35:16 GMT <link>https://svn.boost.org/trac10/ticket/11625#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11625#comment:7</guid> <description> <p> Hi, </p> <p> I just tried your example, and I can reproduce the problem. This is because your class <code>my_class_final</code> does not follow the requirements for the sequence as defined <a href="http://www.boost.org/doc/libs/1_60_0/libs/test/doc/html/boost_test/testing_tools/extended_comparison/collections.html#boost_test.testing_tools.extended_comparison.collections.what_is_a_sequence">here</a>. </p> <p> After adding members <code>size</code> and <code>value_type</code> it works as expected. Would you please confirm? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Raffi Enficiaud</dc:creator> <pubDate>Wed, 13 Jan 2016 09:13:06 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/11625#comment:8 https://svn.boost.org/trac10/ticket/11625#comment:8 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.60.0</span> → <span class="trac-field-new">To Be Determined</span> </li> </ul> Ticket Tony Lewis <tonyelewis@…> Sat, 23 Jan 2016 14:40:28 GMT <link>https://svn.boost.org/trac10/ticket/11625#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11625#comment:9</guid> <description> <p> Thanks for this, yes I can confirm that I'm able to fix my problems by adding <code>size</code> and <code>value_type</code>. Sorry - I should have RTFM properly :-). </p> <p> To make it harder for others to repeat my mistake, it might be useful to: </p> <ul><li>add a note <a href="http://www.boost.org/libs/test/doc/html/boost_test/testing_tools/extended_comparison/collections.html#boost_test.testing_tools.extended_comparison.collections.requirements">here</a> to explicitly state that the comparators must meet the requirements of a sequence and then link to <a href="http://www.boost.org/libs/test/doc/html/boost_test/testing_tools/extended_comparison/collections.html#boost_test.testing_tools.extended_comparison.collections.what_is_a_sequence">the definition further down that page</a> that you highlighted. </li><li>ideally use a <code>Sequence</code> concept to make the compiler errors more helpful. I realise that you may be keen to avoid adding a dependency to the Boost Concept library. </li></ul><p> Again, thanks and apologies. I'm happy for you to close this ticket. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Raffi Enficiaud</dc:creator> <pubDate>Mon, 15 Feb 2016 08:08:57 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/11625#comment:10 https://svn.boost.org/trac10/ticket/11625#comment:10 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> I added an entry to the doc as you suggested (rev 1976cc2). We are not too keen in adding dependencies though. </p> <p> Thanks, Raffi </p> Ticket Tony Lewis <tonyelewis@…> Fri, 19 Feb 2016 14:47:03 GMT <link>https://svn.boost.org/trac10/ticket/11625#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11625#comment:11</guid> <description> <p> Great, thanks. </p> </description> <category>Ticket</category> </item> </channel> </rss>