SQLite testing procedures
Robert Clipsham
robert at octarineparrot.com
Fri Aug 5 13:45:22 PDT 2011
On 05/08/2011 21:13, Robert Clipsham wrote:
> * Forcing coverage of boundary values and boolean vector tests (7.3)
> - SQLite has a testcase() macro which adds additional branches during
> coverage analysis to test boundary conditions and similar.
> - D currently has no way of doing this, it would be a simple (and
> useful) addition to phobos though.
I came up with a quick template to do this - should I make a pull
request, and if so, where to?
----
void coverageTest(size_t line)
{
// Make sure this doesn't get optimized away
static size_t count = 0;
count += line;
}
string testcase(string test, size_t line=__LINE__)()
{
version(D_Coverage)
{
// This has to be on one line so coverage
// line numbers don't get messed up.
return `if (`~test.stringof~`) {
coverageTest(`~line.stringof~`); }`;
}
else
{
return ``;
}
}
----
Usage: mixin(testcase!(`a < b`));
--
Robert
http://octarineparrot.com/
More information about the Digitalmars-d
mailing list