Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogletest Parametrized tests crash
    primarykey
    data
    text
    <p>I've just learned about <a href="https://github.com/google/googletest/blob/master/googletest/docs/advanced.md#value-parameterized-tests" rel="nofollow noreferrer">value-parametrized unit tests in googletest</a> and would like to use them in my project.</p> <p>I wrote a simple parametrized test.</p> <p>Header:</p> <pre><code>#include &lt;gtest/gtest.h&gt; namespace EnsembleClustering { class ParametrizedGTest: public testing::TestWithParam&lt;int&gt; { public: ParametrizedGTest(); virtual ~ParametrizedGTest(); }; } /* namespace EnsembleClustering */ </code></pre> <p>Source:</p> <pre><code>#include "ParametrizedGTest.h" namespace EnsembleClustering { ParametrizedGTest::ParametrizedGTest() { // TODO Auto-generated constructor stub } ParametrizedGTest::~ParametrizedGTest() { // TODO Auto-generated destructor stub } TEST_P(ParametrizedGTest, testParameter) { int n = GetParam(); EXPECT_EQ(n, GetParam()); } INSTANTIATE_TEST_CASE_P(ParametrizedGTestInstance, ParametrizedGTest, ::testing::Values(100)); } /* namespace EnsembleClustering */ </code></pre> <p>Now, when I run googletest as usual, the program crashes without any output. The gdb stack trace is</p> <pre><code>EnsembleClustering-D [C/C++ Application] EnsembleClustering Thread [1] (Suspended : Signal : EXC_BAD_ACCESS:Could not access memory) __gnu_debug::_Safe_sequence_base::_M_attach_single() at 0x100528add __gnu_debug::_Safe_sequence_base::_M_attach() at 0x100528a74 __gnu_debug::_Safe_iterator_base::_M_attach() at 0x100528bfe __gnu_debug::_Safe_iterator_base::_Safe_iterator_base() at safe_base.h:90 0x1000016e9 __gnu_debug::_Safe_iterator&lt;__gnu_cxx::__normal_iterator&lt;testing::internal::ParameterizedTestCaseInfoBase**, std::__cxx1998::vector&lt;testing::internal::ParameterizedTestCaseInfoBase*, std::allocator&lt;testing::internal::ParameterizedTestCaseInfoBase*&gt; &gt; &gt;, std::__debug::vector&lt;testing::internal::ParameterizedTestCaseInfoBase*, std::allocator&lt;testing::internal::ParameterizedTestCaseInfoBase*&gt; &gt; &gt;::_Safe_iterator() at safe_iterator.h:154 0x100002e9c std::__debug::vector&lt;testing::internal::ParameterizedTestCaseInfoBase*, std::allocator&lt;testing::internal::ParameterizedTestCaseInfoBase*&gt; &gt;::begin() at vector:207 0x100001fbe testing::internal::ParameterizedTestCaseRegistry::GetTestCasePatternHolder&lt;EnsembleClustering::ParametrizedGTest&gt;() at gtest-param-util.h:574 0x1000025b0 EnsembleClustering::ParametrizedGTest_testParameter_Test::AddToRegistry() at ParametrizedGTest.cpp:22 0x100001d3f __static_initialization_and_destruction_0() at ParametrizedGTest.cpp:22 0x100001349 _GLOBAL__sub_I_ParametrizedGTest.cpp() at ParametrizedGTest.cpp:32 0x100001424 &lt;...more frames...&gt; gdb </code></pre> <p>Am I doing something wrong or is this a bug in googletest? Can you reproduce this error?</p> <p>EDIT: I am on Mac OS X 10.8.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload