diff options
| author | Tomasz Kramkowski <tk@the-tk.com> | 2021-06-03 16:14:25 +0100 | 
|---|---|---|
| committer | Tomasz Kramkowski <tk@the-tk.com> | 2021-06-03 22:11:07 +0100 | 
| commit | c9a8313e7c883cd864f5fe8e1a527c876f5913f2 (patch) | |
| tree | 710f3fa456e69af1ad6499b7eaa280a7e01da0c2 /test_gen.c | |
| parent | fd74dae4817aedeecbb5a2b9782378db1a3d9e3d (diff) | |
| download | pack-c9a8313e7c883cd864f5fe8e1a527c876f5913f2.tar.gz pack-c9a8313e7c883cd864f5fe8e1a527c876f5913f2.tar.xz pack-c9a8313e7c883cd864f5fe8e1a527c876f5913f2.zip  | |
test_gen: unpack_gen now takes const struct fmtinfo *fi
Also not sure why this wasn't the case from the beginning. The code is
shorter now.
Diffstat (limited to 'test_gen.c')
| -rw-r--r-- | test_gen.c | 15 | 
1 files changed, 5 insertions, 10 deletions
@@ -122,16 +122,11 @@ static void unpack_unsigned(FILE *out, const struct fmtinfo *fi, enum endian e,  		fprintf(out, "\tCHECK_EQUAL(PRIdMAX, (uintmax_t)v[%d], UINTMAX_C(%" PRIuMAX "));\n", i, testval);  } -static void unpack_gen(FILE *out, size_t fmt, int arraysize) +static void unpack_gen(FILE *out, const struct fmtinfo *fi, int arraysize)  {  	int realsize = arraysize == 0 ? 1 : arraysize; -	struct fmtinfo *fi;  	bool sign; -	assert(fmt < sizeof fmtinfo / sizeof fmtinfo[0]); - -	fi = &fmtinfo[fmt]; -  	sign = islower(fi->fmt);  	fprintf(out, "TEST(unpack_simple%d_%s, \"unpack simple", arraysize, cname(fi->type)); @@ -157,9 +152,9 @@ static void unpack_gen(FILE *out, size_t fmt, int arraysize)  int main(void)  {  	FILE *out = stdout; -	for (size_t fmt = 0; fmt < sizeof fmtinfo / sizeof fmtinfo[0]; fmt++) { -		unpack_gen(out, fmt, 0); -		for (int i = 2; i < 4; i++) -			unpack_gen(out, fmt, i); +	for (size_t i = 0; i < sizeof fmtinfo / sizeof fmtinfo[0]; i++) { +		unpack_gen(out, &fmtinfo[i], 0); +		for (int j = 2; j < 4; j++) +			unpack_gen(out, &fmtinfo[i], j);  	}  }  | 
