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

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

Open
jhlegarreta opened this issue Aug 27, 2023 · 0 comments
Labels
type:Enhancement Improvement of existing methods or implementation

Comments

@jhlegarreta
Copy link
Member

jhlegarreta commented Aug 27, 2023

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

@jhlegarreta jhlegarreta added the type:Enhancement Improvement of existing methods or implementation label Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:Enhancement Improvement of existing methods or implementation
Projects
None yet
Development

No branches or pull requests

1 participant