HippoMocks - Use of "ExpectCallFunc" after "NeverCallFunc" for the same function leads to unexpected "HippoMocks::ExpectationException"
<p>Imagine we have a unit test that first executes a sequence of code for which we expect a function <code>someFunc</code> not to be called, then executes a sequence of code for which we expect that function to be called exactly once. Using <a href="http://hippomocks.com" rel="nofollow" title="HippoMocks">HippoMocks</a>, we could write it like this:</p>

<pre><code>#include &lt;hippomocks.h&gt;

void someFunc (void)
{

}

int main (int argc, char ** argv)
{
    MockRepository mocks;
    mocks.autoExpect = false;

    mocks.NeverCallFunc(someFunc); // line 27

    /* some testing code ... */

    /* ... in the course of which someFunc does not get called ... */

    mocks.ExpectCallFunc(someFunc); // line 33

    /* other testing code ... */
    someFunc();
    /* ... in the course of which someFunc got called */

    return 0;
}
</code></pre>

<p>However, when running the above snippet on Windows (compiled with Cygwin toolchain), a <code>HippoMocks::ExpectationException</code> is thrown:</p>

<pre><code>terminate called after throwing an instance of 'HippoMocks::ExpectationException'
what():  Function someFunc() called with mismatching expectation!
Expectations set:
../main.cpp(33) Expectation for someFunc() on the mock at 0x0 was not satisfied.
Functions explicitly expected to not be called:
../main.cpp(27) Result set for someFunc() on the mock at 0x0 was used.
</code></pre>

<p>So I am wondering...</p>

<p>... (1), if HippoMocks is not designed to handle such a scenario. Does expecting that <code>someFunc</code> gets called (line 33) not replace the previous expectation in the corresponding mock respository?</p>

<p>... (2), why the second expectation (line 33) was not satified, as <code>someFunc</code> explicitely gets called. If any, I would have expected the first expectation (line 27) to not having been met?</p>

<p>Interestingly, things work the other way round. The following snippet runs without any issues:</p>

<pre><code>#include &lt;hippomocks.h&gt;

void someFunc (void)
{

}

int main (int argc, char ** argv)
{
    MockRepository mocks;
    mocks.autoExpect = false;

    mocks.ExpectCallFunc(someFunc); // line 27

    /* some testing code ... */
    someFunc();
    /* ... in the course of which someFunc got called */

    mocks.NeverCallFunc(someFunc); // line 33

    /* other testing code ... */

    /* ... in the course of which someFunc does not get called ... */

    /* someFunc(); */ 

    return 0;
}
</code></pre>

<p>Moreover, if a call to <code>someFunc</code> is inserted behind the second expectation in the second snippet (as indicated in the comment), this is detected and reported as violation to the "never call" expectation by HippoMocks as one would expect:</p>

<pre><code>terminate called after throwing an instance of 'HippoMocks::ExpectationException'
  what():  Function someFunc() called with mismatching expectation!
Expectations set:
../main.cpp(27) Expectation for someFunc() on the mock at 0x0 was satisfied.
Functions explicitly expected to not be called:
../main.cpp(33) Result set for someFunc() on the mock at 0x0 was used.
</code></pre>

<p>Any help of a HippoMocks expert would be appreciated...</p>