title: Adding expected calls in a loop
body: <p>This is what I want to achieve. In my test fixture I want  to call a helper functions with a parameter <code>n</code> to tell the test fixture how many initialization sequences should be expected. Some parameters used in the sequences are stored in three <code>std::vector</code> containers; <code>fileDescriptor, handle, selectionObject</code>.</p>
  
  <p>What I have written is this:</p>
  
  <pre><code>void MyTest::init_Ok(uint32_t n)
  {
    for (uint32_t i = 0; i &lt; n; ++i)
    {
      fileDescriptor.push_back(i); // FDs starting at 0
      handle.push_back(reinterpret_cast&lt;void*&gt;(18 + i)); // handles starting at 18
      selectionObject.push_back(555 + i); // SOs starting at 555
  
      EXPECT_CALL(MyMockApi::getApi(), initialize(Pointee(nullptr), StrEq("InitString"), MyMatcher()))
        .WillOnce(DoAll(SetArgPointee&lt;0&gt;(handle[i]),
                        Return(INIT_OK)));
      EXPECT_CALL(MyMockApi::getApi(), selectionObjectGet(handle[i], Pointee(nullptr)))
        .WillOnce(DoAll(SetArgPointee&lt;1&gt;(selectionObject[i]),
                        Return(SELECTION_OK)));
      EXPECT_CALL(MyMockApi::getApi(), finalize(handle[i]))
        .WillOnce(Return(FINAL_OK));
    }
  }
  </code></pre>
  
  <p>I know why it's not working. It is expected that all calls to <code>initialize</code> will be identical but yet I want to perform different actions (parameter depending on loop counter <code>i</code>) for the first, second, third, ..., nth call. The current implementation will only expect one call to <code>initialize</code> no matter parameter <code>n</code>. Is it possible to fix this and keep it a loop somehow, or do I have to add the actions with a <code>WillOnce</code> line for each <code>i</code>? This would mean i have to check <code>n</code> and add different number of <code>WillOnce</code> lines for different possible values of <code>n</code>, which i really want to avoid.</p>