Parameter and template tests
UquoniTest makes it easy to create parameter and template tests, with up to 6 parameters and 3 template types or constants. You first define the parameter test and then instantiate it:
uqtDEFINE_TEST_3PARAM(CalculateC,
int, a,
std::string, b,
int, c)
{
MyClass obj;
obj.SetA(a);
obj.SetB(b);
uqtASSERT(rbEQUAL(obj.GetC(), c));
}
uqtTEST_3PARAM(CalculateC, 4, "abc", 21);
uqtTEST_3PARAM(CalculateC, 6, "def", 28);
uqtTEST_3PARAM(CalculateC, 4, "xy", 35);
uqtTEST_3PARAM(CalculateC, 0, "hello", 0);
uqtTEST_3PARAM(CalculateC, 4, "test", 0);
Template tests are done in a similar way:
uqtDEFINE_TEST_2TMPL(MyTemplateTest, typename, T, int, N)
{
T array[N];
...
}
uqtTEST_2TMPL(MyTemplateTest, std::string, 4);
uqtTEST_2TMPL(MyTemplateTest, float, 2);
You can also have tests with both parameters and templates.
With a test suite you can get data from a source, and use these data to instantiate parameter tests:
uqtAUTO uqtTEST_SUITE(DATA_TXT)
{
std::ifstream file("data.txt");
while (file)
{
int a, c;
std::string b;
file >> a >> b >> c;
uqtADD_TEST_3PARAM(CalculateC, a, b, c);
}
}