Removed the computedName field in testingT; we manage the memory for subtest names in testingTRun() itself.
This commit is contained in:
parent
6412d8365f
commit
57e4e0d13b
|
@ -28,7 +28,6 @@ struct defer {
|
||||||
struct testingT {
|
struct testingT {
|
||||||
// set at test creation time
|
// set at test creation time
|
||||||
const char *name;
|
const char *name;
|
||||||
char *computedName;
|
|
||||||
void (*f)(testingT *, void *);
|
void (*f)(testingT *, void *);
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
|
@ -89,7 +88,6 @@ void testingprivSetRegisterTest(testingSet **pset, const char *name, void (*f)(t
|
||||||
}
|
}
|
||||||
t = (testingT *) testingprivArrayAppend(&(set->tests), 1);
|
t = (testingT *) testingprivArrayAppend(&(set->tests), 1);
|
||||||
initTest(t, name, f, data, file, line);
|
initTest(t, name, f, data, file, line);
|
||||||
t->computedName = testingprivStrdup(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int testcmp(const void *a, const void *b)
|
static int testcmp(const void *a, const void *b)
|
||||||
|
@ -253,6 +251,7 @@ void testingTRun(testingT *t, const char *subname, void (*subfunc)(testingT *t,
|
||||||
{
|
{
|
||||||
testingT *subt;
|
testingT *subt;
|
||||||
testingprivOutbuf *rewrittenName;
|
testingprivOutbuf *rewrittenName;
|
||||||
|
char *fullName;
|
||||||
|
|
||||||
rewrittenName = testingprivNewOutbuf();
|
rewrittenName = testingprivNewOutbuf();
|
||||||
while (*subname != "") {
|
while (*subname != "") {
|
||||||
|
@ -283,17 +282,16 @@ void testingTRun(testingT *t, const char *subname, void (*subfunc)(testingT *t,
|
||||||
testingprivOutbufPrintf(rewrittenName, "\\x%x", (unsigned int) (*subname));
|
testingprivOutbufPrintf(rewrittenName, "\\x%x", (unsigned int) (*subname));
|
||||||
subname++;
|
subname++;
|
||||||
}
|
}
|
||||||
|
fullName = testingSmprintf("%s/%s", t->name, testingprivOutbufString(rewrittenName));
|
||||||
subt = testingprivNew(testingT);
|
|
||||||
initTest(subt, subfunc, data, NULL, 0);
|
|
||||||
subt->computedName = testingSmprintf("%s/%s", t->name, testingprivOutbufString(rewrittenName));
|
|
||||||
testingprivOutbufFree(rewrittenName);
|
testingprivOutbufFree(rewrittenName);
|
||||||
|
|
||||||
|
subt = testingprivNew(testingT);
|
||||||
|
initTest(subt, fullName, subfunc, data, NULL, 0);
|
||||||
subt->opts = t->opts;
|
subt->opts = t->opts;
|
||||||
if (testingprivTRun(subt, t->outbuf) != 0)
|
if (testingprivTRun(subt, t->outbuf) != 0)
|
||||||
t->failed = 1;
|
t->failed = 1;
|
||||||
|
|
||||||
uiprivFree(subt->computedName);
|
|
||||||
uiprivFree(subt);
|
uiprivFree(subt);
|
||||||
|
|
||||||
|
uiprivFree(fullName);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue