Skip to content

Add a data-driven example that is 2-dimensional #300

Description

@eyal0

I got confused when I read the docs about data-driven testing because I made a vector of pair and each element was treated as a single parameter to the macro. But when I needed to add another parameter, I switched to tuple and got a long compiler error that didn't explain my problem well.

For example, this will work:

BOOST_DATA_TEST_CASE(fib_test, bdata::make(std::vector<std::pair<int,int>>{}), sample) {
...
}

and each sample will be a pair. But if you now want to add a third argument, so you switch pair to tuple. It will now fail because you now need three parameters. The sample won't be a tuple. (I suspect that boost is using the std::tuple internally when generating test cases.)

Please add an example how tuple can be used to make a static table. For example:

BOOST_DATA_TEST_CASE(fib_test,
                     bdata::make(
                         std::vector<std::tuple<int,string,string>>{
                           {0, "zero", "cero"},
                           {1, "one", "uno"},
                           {6, "six", "seis"}}),
                     number, english, spanish) {
  BOOST_CHECK_EQUAL(to_english(number), english);
  BOOST_CHECK_EQUAL(to_spanish(number), spanish);
}

Something like that to show off how to make a table.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions