Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type parametrised test cases #1425

Closed
wants to merge 3 commits into from
Closed

Type parametrised test cases #1425

wants to merge 3 commits into from

Conversation

JoeyGrajciar
Copy link
Contributor

Description

This PR adds the support, docs and some unit tests for type parametrised test cases. Currently there is support for up to 8 types for these test cases.

Introduces TEMPLATE_TEST_CASE and TEMPLATE_TEST_CASE_METHOD macros. Usage of these macros is very similar to TEST_CASE and TEST_CASE_METHOD. Difference is that name and description (even empty string) is required as types for test are specified at the end. Example:

TEMPLATE_TEST_CASE("Templated test","",int,float, std::string)
{
    std::vector<TestType> v( 5 );
    REQUIRE( v.size() == 5 );
    REQUIRE( v.capacity() >= 5 );
}

template<typename T>
struct TemplateFixture
{
    TemplateFixture() : m_a( 1 ) {}

    int m_a;
}

TEMPLATE_TEST_CASE_METHOD(TemplateFixture,
    "A TEMPLATE_TEST_CASE_METHOD based test run that fails", 
    "[.][class][template][failing]", int, float, double)
{
        REQUIRE( TemplateFixture<TestType>::m_a == 2 );
}

GitHub Issues

#46 #357 #850 ...
Implementation is based on #382

@codecov
Copy link

codecov bot commented Oct 29, 2018

Codecov Report

Merging #1425 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #1425   +/-   ##
=======================================
  Coverage   80.31%   80.31%           
=======================================
  Files         120      120           
  Lines        3403     3403           
=======================================
  Hits         2733     2733           
  Misses        670      670

include/catch.hpp Outdated Show resolved Hide resolved
@myrgy
Copy link

myrgy commented Nov 8, 2018

Hi all,
is is MR is going to be merged?
it will be extremely useful!

@JoeyGrajciar
Copy link
Contributor Author

@myrgy actually working on v2.0 of this without cap for types :) hold on currently doing some local tests of implementation :)

@horenmar
Copy link
Member

I am going to close this in favour of #1437

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants