From: Glyn M. <gly...@gm...> - 2009-11-09 08:31:31
|
Hi Kim, 2009/11/9 Kim Gräsman <kim...@gm...> > Hi guys, > > On Sun, Nov 8, 2009 at 22:21, Glyn Matthews <gly...@gm...> > wrote: > > > >> > Consequently, I'd like to see all your unit tests repeated for > >> > std::wstring. I think this is important to do because it will really > >> > justify the approach we are taking. > >> > >> I agree. Can this be done automatically? Copy-paste-replace? > > > > I wouldn't recommend copy-paste programming ;) Perhaps just refactor the > > original tests so that they use template member functions: > > > > BOOST_AUTO_TEST_CASE(my_uri_test) { > > boost::network::basic_uri<tags::default_> instance; > > my_uri_test_impl(instance); > > } > > > > BOOST_AUTO_TEST_CASE(my_uri_test_wstring) { > > boost::network::basic_uri<tags::wstring> instance; > > my_uri_test_impl(instance); > > } > > > > or something like that, it won't be difficult. But looking at that, > we'll > > need better names for the tags. > > For the xUnit, OO-style, test frameworks there's a pattern called > Abstract Test Case, where all test methods reside in a base class, > together with one or more abstract methods denoting variance. Then you > create derived, concrete classes that implement the variations for the > specific types, and the runner sees them as separate suites. > > That's essentially what you're describing above, except you would have > to repeat every test case for every variation. > > I wonder if there's a way to use Boost.Test fixtures to implement > Abstract Test Case with a type variation...? > > This seems to be the recommended usage pattern for testing generic components with different template patterns: http://www.boost.org/doc/libs/1_40_0/libs/test/doc/html/utf/usage-recommendations/generic.html#id663542 Thanks, Glyn |