{"issue":{"created_at":"2011-07-29T13:53:37Z","state":"open","updated_at":"2011-12-03T03:18:03Z","comments":10,"user":{"gravatar_id":"a85f07047efea495d19e2b23ddf85db9","id":617250,"url":"https://api.github.com/users/jalfd","avatar_url":"https://secure.gravatar.com/avatar/a85f07047efea495d19e2b23ddf85db9?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"jalfd"},"body":"Does something like this exist? Or would it be possible to add?\r\n\r\nSuppose I need to run the same set of tests on a number of different types, effectively templating the tests on a type parameter.\r\n\r\nI'm not sure what would be an appropriate syntax for it (Boost.Test uses Boost.MPL to create type lists, but adding such a dependency might be awkward, and it requires you to be comfortable with metaprogramming just to define your tests)\r\n\r\nPerhaps something like this?\r\n\r\n```\r\n// indicate I want to define tests that can be templated on a number of different types\r\nTEST_TEMPLATE()\r\n{\r\n    // specify a test case for some type T\r\n    TEST_CASE_T(name, description, T)\r\n    {\r\n        // inside the test case, I can use T as a placeholder for the specific type\r\n        std::vector<T> vec;\r\n        REQUIRE(vec.size() == 0);\r\n    }\r\n    // Register the types I want to run the tests for\r\n    FOR_TYPE(int);\r\n    FOR_TYPE(float)\r\n}\r\n```\r\n\r\nOr perhaps you can come up with a better syntax (or even better, the feature already exists ;))\r\nIn any case, the feature would be very useful.","assignee":null,"number":46,"id":1310153,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"labels":[],"title":"Support for templated tests?","closed_at":null,"html_url":"https://github.com/philsquared/Catch/issues/46","url":"https://api.github.com/repos/philsquared/Catch/issues/46","milestone":null},"action":"created","comment":{"created_at":"2011-12-03T03:18:03Z","updated_at":"2011-12-03T03:18:03Z","user":{"gravatar_id":"66980d1eac668f75552936922491cd82","id":817849,"url":"https://api.github.com/users/samaursa","avatar_url":"https://secure.gravatar.com/avatar/66980d1eac668f75552936922491cd82?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"samaursa"},"body":"I hope I am not intruding. Unless I have misunderstood, you want to run the same test but on different template types? I ran into a similar issue and the simple solution was to make a template function that has all the test and have the test case call it. I believe that is what Phil put down above but the syntax confused me.\r\n\r\nI am with Phil on this one and I would like to see CATCH to be light without any dependencies on external libraries (one of my main reasons for not using any other library). I think what I just said was discussed above but I thought I would put another vote in :)\r\n\r\nThe TEMPLATE_TEST_CASE_# looks interesting. As long as the debugger is OK with it, I personally have no complaints, although I still prefer the explicit template function solution. No need to make CATCH one size fits all.","id":2998794,"url":"https://api.github.com/repos/philsquared/Catch/issues/comments/2998794"}}