c++ - Run typed_test for only one of specified types -


let's suppose i've written code this.

template <typename t>   class footest : public testing::test   {      //class body   };   typedef ::testing::types<int, float/*, , few more*/> testtypes;   typed_test_case(footest, testtypes);     typed_test(footest, test1)   {      //...   }   typed_test(footest, test2)   {      //...;   } 

is there possibility run, example second test, only one of data types specified in testtypes , avoid code duplication?

you should able creating second test class using inheiritance.

this similar approaches on 2 faq entries:

can derive test fixture another?

i have several test cases share same logic...

in code outline below, have separate types 2 disjoint sets.

  template <typename t>   class footest : public testing::test   {      //class body   };    // testtypes contains of types before   // in example, floating point types tested footest.   typedef ::testing::types<float, double, /*, , few more*/> testtypes;    typed_test_case(footest, testtypes);    typed_test(footest, test1)   {      //...   }    // optional, allow reuse test constructor    // , setup/teardown functions   template <typename t>   class extendedfootest : public footest<t>   {}    // , integral types given extended tests   typedef ::testing::types<int, unsigned int, , few more*/> extendedfootypes;    typed_test_case(footest, extendedfootypes);         // repeat tests above   typed_test_case(extendedfootest, extendedfootypes); // plus add new tests.    typed_test(extendedfootest, test2)   {      //...;   } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -