aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2020-09-10 19:15:46 +0100
committerTomasz Kramkowski <tk@the-tk.com>2020-09-10 19:15:46 +0100
commit657e0e7b3611e7746000d30a452fbda8a92ab832 (patch)
tree6381abebe09114ba65dac7f225db8803909e45c0
parentec9cd80fa8d8e295fb2cabc0321df293b471c8be (diff)
downloadpack-657e0e7b3611e7746000d30a452fbda8a92ab832.tar.gz
pack-657e0e7b3611e7746000d30a452fbda8a92ab832.tar.xz
pack-657e0e7b3611e7746000d30a452fbda8a92ab832.zip
Use arrays to simplify future refactoring
-rw-r--r--test_gen.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/test_gen.c b/test_gen.c
index ae796d9..346b2eb 100644
--- a/test_gen.c
+++ b/test_gen.c
@@ -115,21 +115,21 @@ static void generate_simple(FILE *out, enum fmt fmt)
fprintf(out, "TEST(%s)\n", cname(fi->type));
fprintf(out, "{\n");
- fprintf(out, "\t%s v = __LINE__;\n", fi->type);
+ fprintf(out, "\t%s v[1] = { __LINE__ };\n", fi->type);
for (size_t e = 0; e < sizeof endian / sizeof endian[0]; e++) {
for (int i = sign ? -1 : 0; i <= 1; i++) {
- fprintf(out, "\tCHECK_UNPACK(DATA(%s), \"%s%c\", &v);\n",
+ fprintf(out, "\tCHECK_UNPACK(DATA(%s), \"%s%c\", v);\n",
i2bytes(endian[e].e, fi->size, i), endian[e].prefix, fi->fmt);
- fprintf(out, "\tCHECK_EQUAL(PRIdMAX, (intmax_t)v, INTMAX_C(%d));\n", i);
+ fprintf(out, "\tCHECK_EQUAL(PRIdMAX, (intmax_t)v[0], INTMAX_C(%d));\n", i);
}
if (sign) {
- fprintf(out, "\tCHECK_UNPACK(DATA(%s), \"%s%c\", &v);\n",
+ fprintf(out, "\tCHECK_UNPACK(DATA(%s), \"%s%c\", v);\n",
i2bytes(endian[e].e, fi->size, fi->min), endian[e].prefix, fi->fmt);
- fprintf(out, "\tCHECK_EQUAL(PRIdMAX, (intmax_t)v, -INTMAX_C(%" PRIdMAX ")-1);\n", -(fi->min + 1));
+ fprintf(out, "\tCHECK_EQUAL(PRIdMAX, (intmax_t)v[0], -INTMAX_C(%" PRIdMAX ")-1);\n", -(fi->min + 1));
}
- fprintf(out, "\tCHECK_UNPACK(DATA(%s), \"%s%c\", &v);\n",
+ fprintf(out, "\tCHECK_UNPACK(DATA(%s), \"%s%c\", v);\n",
u2bytes(endian[e].e, fi->size, fi->max), endian[e].prefix, fi->fmt);
- fprintf(out, "\tCHECK_EQUAL(PRIuMAX, (uintmax_t)v, UINTMAX_C(%" PRIuMAX "));\n", fi->max);
+ fprintf(out, "\tCHECK_EQUAL(PRIuMAX, (uintmax_t)v[0], UINTMAX_C(%" PRIuMAX "));\n", fi->max);
}
fprintf(out, "\treturn true;\n");
fprintf(out, "}\n");