Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set, in google mock, a void* argument to a set of values?
    primarykey
    data
    text
    <p>I am using google mock to unit test my code, and I am trying to return, as an output argument, a set of values through a void*.</p> <pre><code>uint32_t bigEndianTestValues[BIG_ENDIAN_FIELD_MAX_ELEMENTS] = {0xDEADBEEF, 0xFFFF0000, 0x00000000, 0x00A00F10, 0x11234211}; for (int i = 0; i &lt; BIG_ENDIAN_FIELD_MAX_ELEMENTS; ++i) { EXPECT_CALL( deviceWindow, get(_,sizeof(bigEndianTestValues[0]),_,_) ) .WillOnce(SetArgPointee&lt;2&gt;(bigEndianTestValues[i])) .RetiresOnSaturation(); } </code></pre> <p>My mock contains a method call as follows</p> <pre><code>MOCK_METHOD4(get, void(const size_t, const size_t, void*, nNIAPALS100::tStatus&amp;)); </code></pre> <p>But I get the following error</p> <pre><code>....\include\gmock/gmock-actions.h(693) : error C2100: illegal indirection ....\gmock/gmock-actions.h(369) : see reference to function template instantiation 'void testing::internal::SetArgumentPointeeAction&lt;N,A,kIsProto&gt;::Perform&lt;void,std::tr1::tuple&lt;T0,T1,T2,T3&gt;&gt;(const ArgumentTuple &amp;) const' being compiled with [ N=0x02, A=uint32_t, kIsProto=false, T0=size_t, T1=size_t, T2=void *, T3=nNIAPALS100::tStatus &amp;, ArgumentTuple=std::tr1::tuple&lt;size_t,size_t,void *,nNIAPALS100::tStatus &amp;&gt; ] z:\Perforce\jperetzm_JPERETZM-DT\ThirdPartyExports\googlemock\export\1.6\1.6.0a0\includes\gmock\include\gmock/gmock-actions.h(368) : while compiling class template member function 'void testing::Polymor phicAction&lt;Impl&gt;::MonomorphicImpl&lt;F&gt;::Perform(const std::tr1::tuple&lt;T0,T1,T2,T3&gt; &amp;)' with [ Impl=testing::internal::SetArgumentPointeeAction&lt;0x02,uint32_t,false&gt;, F=void (size_t,size_t,void *,nNIAPALS100::tStatus &amp;), T0=size_t, T1=size_t, T2=void *, T3=nNIAPALS100::tStatus &amp; ] ....\include\gmock/gmock-actions.h(356) : see reference to class template instantiation 'testing::PolymorphicAction&lt;Impl&gt;::MonomorphicImpl&lt;F&gt;' being compiled with [ Impl=testing::internal::SetArgumentPointeeAction&lt;0x02,uint32_t,false&gt;, F=void (size_t,size_t,void *,nNIAPALS100::tStatus &amp;) ] ....\StorageMapRaw_Test.cpp(471) : see reference to function template instantiation 'testing::PolymorphicAction&lt;Impl&gt;::operator testing::Action&lt;F&gt;(void) const&lt;F&gt;' being compiled with [ Impl=testing::internal::SetArgumentPointeeAction&lt;0x02,uint32_t,false&gt;, F=void (size_t,size_t,void *,nNIAPALS100::tStatus &amp;) ] ....include\gmock/gmock-actions.h(693) : error C2440: '=' : cannot convert from 'const uint32_t' to 'void *const 'Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast storageMap_test_win64U_x64_msvc90_debug - 2 error(s), 0 warning(s) </code></pre> <p>It seems that I need to cast the void* to an uint32_t*. Any idea how to do it?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
    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