Boost C++ Libraries: Ticket #8559: Impossible to run single test case if name contains whitespace https://svn.boost.org/trac10/ticket/8559 <p> When using boost test with template based test cases it is possible that name create will contain whitespace (all const arguments, rest up to typeid(T).name). For such a name it is impossible to run test case due to bug in library related to parsing of command line arguments assuming ' ' as a separator and cutting name of test case in place of space, even if properly enclosed in quotes in command line. </p> <p> Simple workaround would be to replace all space characters in name of test case with different one ('_'?). Resolution of <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/3384"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/3384</a> would also solve that problem as well. </p> <pre class="wiki">kamilwitecki@laney:~/projects/c++/boosts_test_bug$ cat main.cpp </pre><div class="wiki-code"><div class="code"><pre><span class="cp">#define BOOST_TEST_MAIN 1</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;boost/test/test_case_template.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;boost/mpl/list.hpp&gt;</span><span class="cp"></span> <span class="k">typedef</span> <span class="n">boost</span><span class="o">::</span><span class="n">mpl</span><span class="o">::</span><span class="n">list</span><span class="o">&lt;</span><span class="kt">int</span><span class="p">,</span> <span class="k">const</span> <span class="kt">int</span><span class="o">&gt;</span> <span class="n">test_types</span><span class="p">;</span> <span class="n">BOOST_AUTO_TEST_CASE_TEMPLATE</span><span class="p">(</span> <span class="n">my_test</span><span class="p">,</span> <span class="n">T</span><span class="p">,</span> <span class="n">test_types</span> <span class="p">)</span> <span class="p">{</span> <span class="n">BOOST_CHECK_EQUAL</span><span class="p">(</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">T</span><span class="p">),</span> <span class="p">(</span><span class="kt">unsigned</span><span class="p">)</span><span class="mi">0</span> <span class="p">);</span> <span class="p">}</span> </pre></div></div><pre class="wiki">kamilwitecki@laney:~/projects/c++/boosts_test_bug$ g++ main.cpp -lboost_unit_test_framework &amp;&amp; ./a.out </pre><pre class="wiki">Running 2 test cases... main.cpp(11): error in "my_test&lt;i&gt;": check sizeof(T) == (unsigned)0 failed [4 != 0] main.cpp(11): error in "my_test&lt;i const&gt;": check sizeof(T) == (unsigned)0 failed [4 != 0] *** 2 failures detected in test suite "Master Test Suite" </pre><pre class="wiki">kamilwitecki@laney:~/projects/c++/boosts_test_bug$ ./a.out -t "my_test&lt;i&gt;" </pre><pre class="wiki">Running 1 test case... main.cpp(11): error in "my_test&lt;i&gt;": check sizeof(T) == (unsigned)0 failed [4 != 0] *** 1 failure detected in test suite "Master Test Suite" </pre><pre class="wiki">kamilwitecki@laney:~/projects/c++/boosts_test_bug$ ./a.out -t "my_test&lt;i const&gt;" </pre><pre class="wiki">Test setup error: no test cases matching filter kamilwitecki@laney:~/projects/c++/boosts_test_bug$ </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8559 Trac 1.4.3 Kamil.Witecki@… Thu, 09 May 2013 20:06:21 GMT attachment set https://svn.boost.org/trac10/ticket/8559 https://svn.boost.org/trac10/ticket/8559 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_test.patch</span> </li> </ul> <p> Simple patch replacing ' ' with '_' in test case name. </p> Ticket hanna@… Tue, 14 May 2013 06:13:49 GMT <link>https://svn.boost.org/trac10/ticket/8559#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8559#comment:1</guid> <description> <p> It appears that not only spaces, but also commas cause the same problem, since they appear in std::string typeid(T).name. Patch should be complemented with: </p> <div class="wiki-code"><div class="code"><pre><span class="n">std</span><span class="o">::</span><span class="n">replace</span><span class="p">(</span><span class="n">full_name</span><span class="p">.</span><span class="n">begin</span><span class="p">(),</span> <span class="n">full_name</span><span class="p">.</span><span class="n">end</span><span class="p">(),</span> <span class="n">boost</span><span class="o">::</span><span class="n">is_any_of</span><span class="p">(</span><span class="s">&quot; ,&quot;</span><span class="p">),</span> <span class="sc">&#39;_&#39;</span><span class="p">);</span> </pre></div></div> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 14 May 2013 06:33:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8559#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8559#comment:2</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8559#comment:1" title="Comment 1">hanna@…</a>: </p> <blockquote class="citation"> <p> It appears that not only spaces, but also commas cause the same problem, since they appear in std::string typeid(T).name. Patch should be complemented with: </p> <div class="wiki-code"><div class="code"><pre><span class="n">std</span><span class="o">::</span><span class="n">replace</span><span class="p">(</span><span class="n">full_name</span><span class="p">.</span><span class="n">begin</span><span class="p">(),</span> <span class="n">full_name</span><span class="p">.</span><span class="n">end</span><span class="p">(),</span> <span class="n">boost</span><span class="o">::</span><span class="n">is_any_of</span><span class="p">(</span><span class="s">&quot; ,&quot;</span><span class="p">),</span> <span class="sc">&#39;_&#39;</span><span class="p">);</span> </pre></div></div></blockquote> <p> Of course, not <code>std::replace(...)</code> but: </p> <div class="wiki-code"><div class="code"><pre><span class="n">std</span><span class="o">::</span><span class="n">replace_if</span><span class="p">(...)</span> </pre></div></div><p> in this case should be used. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Gennadiy Rozental</dc:creator> <pubDate>Tue, 07 Jul 2015 17:45:32 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/8559#comment:3 https://svn.boost.org/trac10/ticket/8559#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.59.0</span> </li> </ul> <p> Eliminated spaces in test case names </p> Ticket