From: Kim G. <kim...@gm...> - 2009-11-09 06:09:41
|
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...? - Kim |