Indented diff bodies (and all other multi-line test log prints) properly.
This commit is contained in:
parent
cceae4845e
commit
a632d10701
|
@ -213,7 +213,7 @@ static const char *basename(const char *file)
|
||||||
void testingprivTLogvfFull(testingT *t, const char *file, long line, const char *format, va_list ap)
|
void testingprivTLogvfFull(testingT *t, const char *file, long line, const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
testingprivOutbufPrintf(t->outbuf, "%s:%ld: ", basename(file), line);
|
testingprivOutbufPrintf(t->outbuf, "%s:%ld: ", basename(file), line);
|
||||||
testingprivOutbufVprintf(t->outbuf, format, ap);
|
testingprivOutbufVprintfIndented(t->outbuf, format, ap);
|
||||||
testingprivOutbufPrintf(t->outbuf, "\n");
|
testingprivOutbufPrintf(t->outbuf, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -212,6 +212,31 @@ void testingprivOutbufVprintf(testingprivOutbuf *o, const char *fmt, va_list ap)
|
||||||
testingprivVsnprintf(dest, n + 1, fmt, ap);
|
testingprivVsnprintf(dest, n + 1, fmt, ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testingprivOutbufVprintfIndented(testingprivOutbuf *o, const char *fmt, va_list ap)
|
||||||
|
{
|
||||||
|
char *buf;
|
||||||
|
char *lineStart, *lineEnd;
|
||||||
|
const char *indent;
|
||||||
|
|
||||||
|
buf = testingprivVsmprintf(fmt, ap);
|
||||||
|
|
||||||
|
lineStart = buf;
|
||||||
|
indent = "";
|
||||||
|
for (;;) {
|
||||||
|
lineEnd = strchr(lineStart, '\n');
|
||||||
|
if (lineEnd == NULL)
|
||||||
|
break;
|
||||||
|
*lineEnd = '\0';
|
||||||
|
testingprivOutbufPrintf(o, "%s%s\n", indent, lineStart);
|
||||||
|
lineStart = lineEnd + 1;
|
||||||
|
indent = " ";
|
||||||
|
}
|
||||||
|
// and print the last line fragment, if any
|
||||||
|
if (*lineStart != '\0')
|
||||||
|
testingprivOutbufPrintf(o, "%s%s", indent, lineStart);
|
||||||
|
testingprivFree(buf);
|
||||||
|
}
|
||||||
|
|
||||||
void testingprivOutbufPrintf(testingprivOutbuf *o, const char *fmt, ...)
|
void testingprivOutbufPrintf(testingprivOutbuf *o, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
|
@ -46,6 +46,7 @@ typedef struct testingprivOutbuf testingprivOutbuf;
|
||||||
extern testingprivOutbuf *testingprivNewOutbuf(void);
|
extern testingprivOutbuf *testingprivNewOutbuf(void);
|
||||||
extern void testingprivOutbufFree(testingprivOutbuf *o);
|
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 testingprivOutbufVprintfIndented(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);
|
extern const char *testingprivOutbufString(testingprivOutbuf *o);
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include "lib/testing.h"
|
#include "lib/testing.h"
|
||||||
#include "lib/timer.h"
|
#include "lib/timer.h"
|
||||||
|
|
||||||
// TODO this should have the case reports indented
|
|
||||||
#define diff(t, clause, fmt, got, want) testingTErrorf(t, "%s:\ngot " fmt "\nwant " fmt, clause, got, want)
|
#define diff(t, clause, fmt, got, want) testingTErrorf(t, "%s:\ngot " fmt "\nwant " fmt, clause, got, want)
|
||||||
#define diff_2str(t, clause, clause2, fmt, got, want) testingTErrorf(t, "%s %s:\ngot " fmt "\nwant " fmt, clause, clause2, got, want)
|
#define diff_2str(t, clause, clause2, fmt, got, want) testingTErrorf(t, "%s %s:\ngot " fmt "\nwant " fmt, clause, clause2, got, want)
|
||||||
#define diff2(t, clause, fmts, got1, got2, want1, want2) testingTErrorf(t, "%s:\ngot " fmts "\nwant " fmts, clause, got1, got2, want1, want2)
|
#define diff2(t, clause, fmts, got1, got2, want1, want2) testingTErrorf(t, "%s:\ngot " fmts "\nwant " fmts, clause, got1, got2, want1, want2)
|
||||||
|
|
Loading…
Reference in New Issue