title: How to test the same behaviour for multiple templated classes with different templates in Google Test?
body: <p>I am practicing sorting algorithms in C++ 17 and have implemented my unittests as follows (the following compiles and all tests are green):</p>
  <pre><code>template &lt;typename T&gt;
  class SortingmethodTest : public ::testing::Test
  {
  protected:   
      T sortingmethod;
  
      static constexpr int amount_test_data[7] = {0, 4, 8, 10, 256, 1000, 1234};
  };
  
  using sortingmethods = ::testing::Types&lt;STLSort&lt;int&gt;,
                                           InsertionSort&lt;int&gt;,
                                           ShellSort&lt;int&gt;,
                                           MergeSort&lt;int&gt;,
                                           OptimizedMergeSort&lt;int&gt;,
                                           QuickSort&lt;int&gt;&gt;;
  
  TYPED_TEST_SUITE(SortingmethodTest, sortingmethods);
  
  TYPED_TEST(SortingmethodTest, sort)
  {
      for (const auto&amp; amount : this-&gt;amount_test_data)
      {
          Sortvector&lt;int&gt; test(amount);
          test.vul_random_zonder_dubbels(); // Fills the vector
  
          this-&gt;sortingmethod(test); // operator() of the sortmethod used (STLSort, InsertionSort, ...) sorts the vector
  
          ASSERT_TRUE(test.is_range());
          ASSERT_TRUE(test.is_gesorteerd());
          ASSERT_TRUE(std::is_sorted(test.begin(), test.end()));
      }
  }
  
  TYPED_TEST(SortingmethodTest, sort_reverse)
  {
      // ...
  }
  
  TYPED_TEST(SortingmethodTest, sort_already_sorted)
  {
      // ...
  }
  
  TYPED_TEST(SortingmethodTest, sort_empty)
  {
      // ...
  }
  </code></pre>
  <p>I would like to repeat the same tests for other types than ints, e.g.</p>
  <pre><code>STLSort&lt;int&gt;,
  InsertionSort&lt;int&gt;,
  ShellSort&lt;int&gt;,
  MergeSort&lt;int&gt;,
  OptimizedMergeSort&lt;int&gt;,
  QuickSort&lt;int&gt;
  
  STLSort&lt;double&gt;,
  InsertionSort&lt;double&gt;,
  ShellSort&lt;double&gt;,
  MergeSort&lt;double&gt;,
  OptimizedMergeSort&lt;double&gt;,
  QuickSort&lt;double&gt;
  
  STLSort&lt;CustomType&gt;,
  InsertionSort&lt;CustomType&gt;,
  ShellSort&lt;CustomType&gt;,
  MergeSort&lt;CustomType&gt;,
  OptimizedMergeSort&lt;CustomType&gt;,
  QuickSort&lt;CustomType&gt;
  
  ...
  </code></pre>
  <p>How can I do this in C++ with google test as cleanly and with as much reuse as possible? I am getting lost in the jungle of typed tests and type-parameterized tests [1]: when should I use one or the other?</p>
  <p>With kind regards,</p>
  <p>Marten</p>
  <p>[1] <a href="https://github.com/google/googletest/blob/master/docs/advanced.md#type-parameterized-tests" rel="nofollow noreferrer">https://github.com/google/googletest/blob/master/docs/advanced.md#type-parameterized-tests</a></p>