And added testingprivOutbufString() and enabled testingTRun(). Now to rewrite the events tests to use it.

This commit is contained in:
Pietro Gagliardi 2019-05-20 22:03:56 -04:00
parent 57e4e0d13b
commit 102dff6489
3 changed files with 12 additions and 7 deletions

View File

@ -246,15 +246,13 @@ void testingTDefer(testingT *t, void (*f)(testingT *t, void *data), void *data)
} }
void testingTRun(testingT *t, const char *subname, void (*subfunc)(testingT *t, void *data), void *data) void testingTRun(testingT *t, const char *subname, void (*subfunc)(testingT *t, void *data), void *data)
{}
#if 0
{ {
testingT *subt; testingT *subt;
testingprivOutbuf *rewrittenName; testingprivOutbuf *rewrittenName;
char *fullName; char *fullName;
rewrittenName = testingprivNewOutbuf(); rewrittenName = testingprivNewOutbuf();
while (*subname != "") { while (*subname != '\0') {
const char *replaced; const char *replaced;
replaced = NULL; replaced = NULL;
@ -282,7 +280,7 @@ 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)); fullName = testingprivSmprintf("%s/%s", t->name, testingprivOutbufString(rewrittenName));
testingprivOutbufFree(rewrittenName); testingprivOutbufFree(rewrittenName);
subt = testingprivNew(testingT); subt = testingprivNew(testingT);
@ -290,8 +288,7 @@ void testingTRun(testingT *t, const char *subname, void (*subfunc)(testingT *t,
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); testingprivFree(subt);
uiprivFree(fullName); testingprivFree(fullName);
} }
#endif

View File

@ -267,3 +267,10 @@ void testingprivOutbufAppendOutbuf(testingprivOutbuf *o, testingprivOutbuf *src)
if (hasTrailingBlankLine) if (hasTrailingBlankLine)
buf[trailingBlankLinePos] = '\n'; buf[trailingBlankLinePos] = '\n';
} }
const char *testingprivOutbufString(testingprivOutbuf *o)
{
if (o->buf.buf == NULL)
return "";
return o->buf.buf;
}

View File

@ -48,3 +48,4 @@ extern void testingprivOutbufFree(testingprivOutbuf *o);
extern void testingprivOutbufVprintf(testingprivOutbuf *o, const char *fmt, va_list ap); extern void testingprivOutbufVprintf(testingprivOutbuf *o, const char *fmt, va_list ap);
extern void testingprivOutbufPrintf(testingprivOutbuf *o, const char *fmt, ...); extern void testingprivOutbufPrintf(testingprivOutbuf *o, const char *fmt, ...);
extern void testingprivOutbufAppendOutbuf(testingprivOutbuf *o, testingprivOutbuf *src); extern void testingprivOutbufAppendOutbuf(testingprivOutbuf *o, testingprivOutbuf *src);
extern const char *testingprivOutbufString(testingprivOutbuf *o);