Changed testingSet to use testingprivArray.
This commit is contained in:
parent
2d8764f06b
commit
40508a457c
|
@ -23,6 +23,7 @@ struct uiprivArray {
|
||||||
size_t nGrow;
|
size_t nGrow;
|
||||||
const char *what;
|
const char *what;
|
||||||
};
|
};
|
||||||
|
#define uiprivArrayStaticInit(T, grow, whatstr) { NULL, 0, 0, sizeof (T), grow, whatstr }
|
||||||
#define uiprivArrayInit(arr, T, grow, whatstr) \
|
#define uiprivArrayInit(arr, T, grow, whatstr) \
|
||||||
memset(&(arr), 0, sizeof (uiprivArray)); \
|
memset(&(arr), 0, sizeof (uiprivArray)); \
|
||||||
arr.elemsize = sizeof (T); \
|
arr.elemsize = sizeof (T); \
|
||||||
|
|
|
@ -161,37 +161,28 @@ static void initTest(testingT *t, const char *name, void (*f)(testingT *), const
|
||||||
t->line = line;
|
t->line = line;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define nGrow 32
|
|
||||||
|
|
||||||
struct testingSet {
|
struct testingSet {
|
||||||
testingT *tests;
|
testingprivArray tests;
|
||||||
size_t len;
|
|
||||||
size_t cap;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static testingSet mainTests = { NULL, 0, 0 };
|
static testingSet mainTests = { testingprivArrayStaticInit(testingT, 32, "testingT[]") };
|
||||||
|
|
||||||
void testingprivSetRegisterTest(testingSet **pset, const char *name, void (*f)(testingT *), const char *file, long line)
|
void testingprivSetRegisterTest(testingSet **pset, const char *name, void (*f)(testingT *), const char *file, long line)
|
||||||
{
|
{
|
||||||
testingSet *set;
|
testingSet *set;
|
||||||
|
testingT *t;
|
||||||
|
|
||||||
set = &mainTests;
|
set = &mainTests;
|
||||||
if (pset != NULL) {
|
if (pset != NULL) {
|
||||||
set = *pset;
|
set = *pset;
|
||||||
if (set == NULL) {
|
if (set == NULL) {
|
||||||
set = testingprivNew(testingSet);
|
set = testingprivNew(testingSet);
|
||||||
|
testingprivArrayInit(set->tests, testingT, 32, "testingT[]");
|
||||||
*pset = set;
|
*pset = set;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (set->len == set->cap) {
|
t = (testingT *) testingprivArrayAppend(&(set->tests), 1);
|
||||||
size_t prevcap;
|
initTest(t, name, f, file, line);
|
||||||
|
|
||||||
prevcap = set->cap;
|
|
||||||
set->cap += nGrow;
|
|
||||||
set->tests = testingprivResizeArray(set->tests, testingT, prevcap, set->cap);
|
|
||||||
}
|
|
||||||
initTest(set->tests + set->len, name, f, file, line);
|
|
||||||
set->len++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int testcmp(const void *a, const void *b)
|
static int testcmp(const void *a, const void *b)
|
||||||
|
@ -234,9 +225,9 @@ static void testingprivSetRun(testingSet *set, const testingOptions *options, in
|
||||||
char timerstr[timerDurationStringLen];
|
char timerstr[timerDurationStringLen];
|
||||||
int printStatus;
|
int printStatus;
|
||||||
|
|
||||||
qsort(set->tests, set->len, sizeof (testingT), testcmp);
|
testingprivArrayQsort(&(set->tests), testcmp);
|
||||||
t = set->tests;
|
t = (testingT *) (set->tests.buf);
|
||||||
for (i = 0; i < set->len; i++) {
|
for (i = 0; i < set->tests.len; i++) {
|
||||||
if (options->Verbose)
|
if (options->Verbose)
|
||||||
outbufPrintf(NULL, indent, "=== RUN %s", t->name);
|
outbufPrintf(NULL, indent, "=== RUN %s", t->name);
|
||||||
t->indent = indent + 1;
|
t->indent = indent + 1;
|
||||||
|
@ -273,7 +264,7 @@ void testingSetRun(testingSet *set, const struct testingOptions *options, int *a
|
||||||
set = &mainTests;
|
set = &mainTests;
|
||||||
if (options == NULL)
|
if (options == NULL)
|
||||||
options = &defaultOptions;
|
options = &defaultOptions;
|
||||||
if (set->len == 0)
|
if (set->tests.len == 0)
|
||||||
return;
|
return;
|
||||||
testingprivSetRun(set, options, 0, anyFailed);
|
testingprivSetRun(set, options, 0, anyFailed);
|
||||||
*anyRun = 1;
|
*anyRun = 1;
|
||||||
|
|
|
@ -18,6 +18,7 @@ struct testingprivArray {
|
||||||
size_t nGrow;
|
size_t nGrow;
|
||||||
const char *what;
|
const char *what;
|
||||||
};
|
};
|
||||||
|
#define testingprivArrayStaticInit(T, grow, whatstr) { NULL, 0, 0, sizeof (T), grow, whatstr }
|
||||||
#define testingprivArrayInit(arr, T, grow, whatstr) \
|
#define testingprivArrayInit(arr, T, grow, whatstr) \
|
||||||
memset(&(arr), 0, sizeof (testingprivArray)); \
|
memset(&(arr), 0, sizeof (testingprivArray)); \
|
||||||
arr.elemsize = sizeof (T); \
|
arr.elemsize = sizeof (T); \
|
||||||
|
|
Loading…
Reference in New Issue