aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test_gen.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/test_gen.c b/test_gen.c
index cc78c40..12c3c16 100644
--- a/test_gen.c
+++ b/test_gen.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 Tomasz Kramkowski <tk@the-tk.com>
+ * Copyright (C) 2020-2021 Tomasz Kramkowski <tk@the-tk.com>
* SPDX-License-Identifier: MIT
*/
#include <assert.h>
@@ -99,7 +99,7 @@ static const char *i2bytes(enum endian e, int n, intmax_t v)
return u2bytes(e, n, i2u(n, v));
}
-static void signed_check(FILE *out, const struct fmtinfo *fi, enum endian e, intmax_t testval, int arraysize)
+static void unpack_signed(FILE *out, const struct fmtinfo *fi, enum endian e, intmax_t testval, int arraysize)
{
char sizeprefix[11] = "";
const char *data;
@@ -118,7 +118,7 @@ static void signed_check(FILE *out, const struct fmtinfo *fi, enum endian e, int
fprintf(out, "\tCHECK_EQUAL(PRIdMAX, (intmax_t)v[%d], -INTMAX_C(%" PRIdMAX ")-1);\n", i, -(testval + 1));
}
-static void unsigned_check(FILE *out, const struct fmtinfo *fi, enum endian e, uintmax_t testval, int arraysize)
+static void unpack_unsigned(FILE *out, const struct fmtinfo *fi, enum endian e, uintmax_t testval, int arraysize)
{
char sizeprefix[11] = "";
const char *data;
@@ -137,7 +137,7 @@ static void unsigned_check(FILE *out, const struct fmtinfo *fi, enum endian e, u
fprintf(out, "\tCHECK_EQUAL(PRIdMAX, (uintmax_t)v[%d], UINTMAX_C(%" PRIuMAX "));\n", i, testval);
}
-static void generate_simple(FILE *out, enum fmt fmt, int arraysize)
+static void unpack_gen(FILE *out, enum fmt fmt, int arraysize)
{
int realsize = arraysize == 0 ? 1 : arraysize;
struct fmtinfo *fi;
@@ -160,10 +160,10 @@ static void generate_simple(FILE *out, enum fmt fmt, int arraysize)
fprintf(out, " };\n");
for (size_t e = 0; e < sizeof endian / sizeof endian[0]; e++) {
for (int i = sign ? -1 : 0; i <= 1; i++)
- signed_check(out, fi, e, i, arraysize);
+ unpack_signed(out, fi, e, i, arraysize);
if (sign)
- signed_check(out, fi, e, fi->min, arraysize);
- unsigned_check(out, fi, e, fi->max, arraysize);
+ unpack_signed(out, fi, e, fi->min, arraysize);
+ unpack_unsigned(out, fi, e, fi->max, arraysize);
}
fprintf(out, "\treturn true;\n");
fprintf(out, "}\n");
@@ -173,8 +173,8 @@ int main(void)
{
FILE *out = stdout;
for (enum fmt fmt = FMT_BEGIN; fmt < FMT_END; fmt++) {
- generate_simple(out, fmt, 0);
+ unpack_gen(out, fmt, 0);
for (int i = 2; i < 4; i++)
- generate_simple(out, fmt, i);
+ unpack_gen(out, fmt, i);
}
}