Move must_alloc into test.h

This commit is contained in:
Laria 2021-12-16 22:50:14 +01:00
parent 025fd61abd
commit 84f127bfec
2 changed files with 10 additions and 10 deletions

View file

@ -127,6 +127,16 @@ test_main(int argc, const char **argv, struct testdef tests[])
return allok ? 0 : 1;
}
static void *
must_alloc(testctx t, size_t size)
{
void *out = malloc(size);
if (out == NULL) {
test_fatalf(t, "Failed allocating %d bytes of memory", size);
}
return out;
}
#define TESTS_BEGIN \
int main(int argc, const char **argv) \
{ \

View file

@ -4,16 +4,6 @@
#include "test.h"
static void *
must_alloc(testctx t, size_t size)
{
void *out = malloc(size);
if (out == NULL) {
test_fatalf(t, "Failed allocating %d bytes of memory", size);
}
return out;
}
struct tokenizer_test {
testctx t;
apfl_tokenizer_ptr tokenizer;