Skip to content

Create Cartesian product testing utility function to test dimensionality combinations #4174

@jhlegarreta

Description

@jhlegarreta

Description

Due to templates requiring values to be known at compile time, it is currently not possible to create Cartesian products of input/output dimensionality values so that the instantiation of filters that support only some given values can be tested with products of unsupported values.

Expected behavior

A Create Cartesian product testing utility function is used to test unsupported dimensionality combinations.

Actual behavior

Input/output dimensionality values that are not supported (e.g. trigger an exception) need to be fully developed/unfolded in tests, e.g.
https://github.com/InsightSoftwareConsortium/ITK/pull/4166/files#r1306746602

Additional Information

Something along these lines (templates could be used):

#include <iostream>
#include <vector>
#include <utility>

int main()
{
    unsigned int a[4]= {1,2,3,4};
    unsigned int b[3] = {1,2,4};
    std::vector<std::pair<unsigned int, unsigned int>> prod;

    for (int i = 0; i < sizeof(a)/sizeof(a[0]); i++)
    {
        for (int j = 0; j < sizeof(b)/sizeof(b[0]); j++)
        {
            prod.push_back(std::make_pair(a[i], b[j]));
        }  
    }

    for (auto i : prod)
    {
        std::cout << i.first << "," << i.second << std::endl;
    }

    return 0;
}

e.g. https://onlinegdb.com/v4xEK5s2H

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:EnhancementImprovement of existing methods or implementation

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions