title: Can Hippomocks set expectations for the same MockRepository in different source files?
body: <p>I would like to have multiple tests in multiple files be able to call a separately-compiled utility method from another file that sets up the same expectations for each test. However, Hippomocks seems to have a problem with setting expectations for the  same MockRepository in different source files.</p>
  
  <p>Here's a simple example:</p>
  
  <p>file1.cpp is:</p>
  
  <pre><code>void SetOtherExpectations(MockRepository &amp;mocks);
  
  int Method45()
  {
      return -45; 
  }
  int Method88()
  {
      return -88;
  }
  
  TEST(TestOfSettingValueInAnotherSourceFile)
  {
      MockRepository mocks;
      mocks.OnCallFunc(Method45).Return(45);
      mocks.OnCallFunc(Method88).Return(88);
      SetOtherExpectations(mocks);
      testEqual(45, Method45()); // Failed Condition: (Expected: &lt;45&gt;, actual: &lt;8888&gt;
  }
  </code></pre>
  
  <p>file2.cpp is:</p>
  
  <pre><code>int MethodInt(int)
  {
      return -145;
  }
  int MethodChar(char)
  {
      return -188;
  }
  
  void SetOtherExpectations(testFramework::MockRepository &amp;mocks)
  {
      mocks.OnCallFunc(MethodChar).Return(8888); // Line A
      mocks.OnCallFunc(MethodInt).Return(9999); // Line B
  }
  </code></pre>
  
  <p>If I swap line A and B, the Method45 call now returns 9999. It turns out that when the Method45 call is made, the search for the matching expectation finds the first mocked function in file2 before it finds the correct mocked function from file1. </p>
  
  <p>There are 4 mocked methods in the MockRepository, but Hippomocks assigns a <code>funcIndex</code> value on a per-source-file basis, since it uses the <code>__COUNTER__</code> preprocessor variable (which starts at 0 in each source file and is incremented by 1 every time it is used in that source file) in the calls to RegisterExpect. Therefore each subsequent expectation setting in a separate source file “hides” all previous expectations set with that index.</p>
  
  <p>It seems like I need to include as inline code all the utility functions that set expectations into each separately-compiled source file, which is not a great solution. Is there any other way to do this?</p>