Skip to content

Commit 34043e3

Browse files
committed
Add script to check float test names, and fix the inconsistencies it found
1 parent 9a6648b commit 34043e3

3 files changed

Lines changed: 359 additions & 29 deletions

File tree

test/pico_float_test/custom_double_funcs_test.c

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ int test() {
117117
test_checkd(int642double(INT32_MIN+1ll), -2147483647.0, "int642double9");
118118
// todo test correct rounding around maximum precision
119119
test_checkd(int642double(INT64_MAX), 9223372036854775807.0, "int642double10");
120-
test_checkd(int642double(INT64_MIN), -9223372036854775808.0, "int642doubl11e");
120+
test_checkd(int642double(INT64_MIN), -9223372036854775808.0, "int642double11");
121121

122122
printf("uint642double\n");
123123
test_checkd(uint642double(0), 0.0, "uint642double1");
@@ -147,31 +147,33 @@ int test() {
147147
test_checkd(ufix2double(0xa0000000, 30), 2.5, "ufix2double1");
148148
test_checkd(ufix2double(3, -4), 48.0, "ufix2double2");
149149

150+
printf("fix2double_N\n");
150151
test_checkd(fix2double_8(128), 0.5, "fix2double_8_1");
151152
test_checkd(fix2double_8(-128), -0.5, "fix2double_8_2");
152-
test_checkd(fix2double_16(8192), 0.125, "fix2double_8_3");
153-
test_checkd(fix2double_16(-8192), -0.125, "fix2double_8_4");
154-
test_checkd(fix2double_24(3<<23), 1.5, "fix2double_8_5");
155-
test_checkd(fix2double_24(-(3<<23)), -1.5, "fix2double_8_6");
153+
test_checkd(fix2double_16(8192), 0.125, "fix2double_16_1");
154+
test_checkd(fix2double_16(-8192), -0.125, "fix2double_16_2");
155+
test_checkd(fix2double_24(3<<23), 1.5, "fix2double_24_1");
156+
test_checkd(fix2double_24(-(3<<23)), -1.5, "fix2double_24_2");
156157

157-
test_checkd(ufix2double_8(128), 0.5, "fix2double_8_1");
158+
printf("ufix2double_N\n");
159+
test_checkd(ufix2double_8(128), 0.5, "ufix2double_8_1");
158160
test_checkd(ufix2double_8(-128), 16777215.5, "ufix2double_8_2");
159-
test_checkd(ufix2double_16(8192), 0.125, "ufix2double_8_3");
160-
test_checkd(ufix2double_16(-8192), 65535.875, "ufix2double_8_4");
161-
test_checkd(ufix2double_24(3<<23), 1.5, "ufix2double_8_5");
162-
test_checkd(ufix2double_24(-(3<<23)), 254.5, "ufix2double_8_6");
161+
test_checkd(ufix2double_16(8192), 0.125, "ufix2double_16_1");
162+
test_checkd(ufix2double_16(-8192), 65535.875, "ufix2double_16_2");
163+
test_checkd(ufix2double_24(3<<23), 1.5, "ufix2double_24_1");
164+
test_checkd(ufix2double_24(-(3<<23)), 254.5, "ufix2double_24_2");
163165
#endif
164166

165167
#if PICO_DOUBLE_HAS_FIX64_TO_DOUBLE_CONVERSIONS
166-
printf("fix64double\n");
168+
printf("fix642double\n");
167169
// todo test correct rounding around maximum precision
168170
test_checkd(fix642double(-0xa000000000ll, 38), -2.5, "fix642double1");
169171
test_checkd(fix642double(-3, -34), -51539607552.0, "fix642double2");
170172

171173
printf("ufix642double\n");
172174
// todo test correct rounding around maximum precision
173175
test_checkd(ufix642double(0xa000000000ll, 38), 2.5, "ufix642double1");
174-
test_checkd(ufix642double(3, -34), 51539607552.0, "fix64double2");
176+
test_checkd(ufix642double(3, -34), 51539607552.0, "ufix642double2");
175177
#endif
176178

177179
#if PICO_DOUBLE_HAS_DOUBLE_TO_FIX32_M_CONVERSIONS
@@ -255,7 +257,7 @@ int test() {
255257
test_checki64(double2fix64(-3.24999, 2), -13, "double2fix648");
256258
test_checki64(double2fix64(-3.25, 2), -13, "double2fix649");
257259
test_checki64(double2fix64(-3.0, -1), -2, "double2fix6410"); // not very useful
258-
test_checki64(double2fix64(2147483648.0 * 2147483648.0, 16), INT64_MAX, "double2ufix6411");
260+
test_checki64(double2fix64(2147483648.0 * 2147483648.0, 16), INT64_MAX, "double2fix6411");
259261
test_checki64(double2fix64(0.0, 16), 0, "double2fix6412");
260262
test_checki64(double2fix64(-0.0, 16), 0, "double2fix6413");
261263
test_checki64(double2fix64(0.0, -16), 0, "double2fix6412b");
@@ -362,10 +364,10 @@ int test() {
362364
test_checku(double2ufix_z(3.24999, 2), 12, "double2ufix_z6");
363365
test_checku(double2ufix_z(3.25, 2), 13, "double2ufix_z7");
364366
test_checku(double2ufix_z(3.0, -1), 1, "double2ufix_z8"); // not very useful
365-
test_checki(double2ufix_z(0.0, 16), 0, "double2ufix_z9");
366-
test_checki(double2ufix_z(-0.0, 16), 0, "double2ufix_z10");
367-
test_checki(double2ufix_z(0.0, -16), 0, "double2ufix_z11");
368-
test_checki(double2ufix_z(-0.0, -16), 0, "double2ufix_z12");
367+
test_checku(double2ufix_z(0.0, 16), 0, "double2ufix_z9");
368+
test_checku(double2ufix_z(-0.0, 16), 0, "double2ufix_z10");
369+
test_checku(double2ufix_z(0.0, -16), 0, "double2ufix_z11");
370+
test_checku(double2ufix_z(-0.0, -16), 0, "double2ufix_z12");
369371
u64d.u = 0x7fe0000000012345ull;
370372
test_checku(double2ufix_z(u64d.d, 0), UINT32_MAX, "double2ufix_z13a");
371373
test_checku(double2ufix_z(u64d.d, 1), UINT32_MAX, "double2ufix_z13b");
@@ -433,7 +435,7 @@ int test() {
433435
test_checku64(double2ufix64_z(-3.5, 8), 0, "double2ufix64_z2");
434436
test_checku64(double2ufix64_z(32768.0, 16), 32768ll << 16, "double2ufix64_z3");
435437
test_checku64(double2ufix64_z(65536.0, 16), 65536ll << 16, "double2ufix64_z4");
436-
test_checki64(double2ufix64_z(65536.0 * 65536.0 * 65536.0, 16), UINT64_MAX, "double2ufix64_z4b");
438+
test_checku64(double2ufix64_z(65536.0 * 65536.0 * 65536.0, 16), UINT64_MAX, "double2ufix64_z4b");
437439
test_checku64(double2ufix64_z(INFINITY, 16), UINT64_MAX, "double2ufix64_z5");
438440
test_checku64(double2ufix64_z(-INFINITY, 16), 0, "double2ufix64_z5b");
439441
test_checku64(double2ufix64_z(INFINITY, -16), UINT64_MAX, "double2ufix64_z5c");

test/pico_float_test/custom_float_funcs_test.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,18 +243,18 @@ int test() {
243243
printf("fix2float_N\n");
244244
test_checkf(fix2float_8(128), 0.5f, "fix2float_8_1");
245245
test_checkf(fix2float_8(-128), -0.5f, "fix2float_8_2");
246-
test_checkf(fix2float_16(8192), 0.125f, "fix2float_8_3");
247-
test_checkf(fix2float_16(-8192), -0.125f, "fix2float_8_4");
248-
test_checkf(fix2float_24(3<<23), 1.5f, "fix2float_8_5");
249-
test_checkf(fix2float_24(-(3<<23)), -1.5f, "fix2float_8_6");
246+
test_checkf(fix2float_16(8192), 0.125f, "fix2float_16_1");
247+
test_checkf(fix2float_16(-8192), -0.125f, "fix2float_16_2");
248+
test_checkf(fix2float_24(3<<23), 1.5f, "fix2float_24_1");
249+
test_checkf(fix2float_24(-(3<<23)), -1.5f, "fix2float_24_2");
250250

251251
printf("ufix2float_N\n");
252252
test_checkf(ufix2float_8(128), 0.5f, "ufix2float_8_1");
253253
test_checkf(ufix2float_8(-128), 16777216.f, "ufix2float_8_2");
254-
test_checkf(ufix2float_16(8192), 0.125f, "ufix2floa4t_8_3");
255-
test_checkf(ufix2float_16(-8192), 65535.875f, "ufix2float_8_4");
256-
test_checkf(ufix2float_24(3<<23), 1.5f, "ufix2float_8_5");
257-
test_checkf(ufix2float_24(-(3<<23)), 254.5f, "ufix2float_8_6");
254+
test_checkf(ufix2float_16(8192), 0.125f, "ufix2float_16_1");
255+
test_checkf(ufix2float_16(-8192), 65535.875f, "ufix2float_16_2");
256+
test_checkf(ufix2float_24(3<<23), 1.5f, "ufix2float_24_1");
257+
test_checkf(ufix2float_24(-(3<<23)), 254.5f, "ufix2float_24_2");
258258

259259
#endif
260260

@@ -436,8 +436,6 @@ int test() {
436436
test_checku64(float2ufix64(-INFINITY, -16), 0, "float2ufix645d");
437437
test_checku64(float2ufix64(INFINITY, 0), UINT64_MAX, "float2ufix645e");
438438
test_checku64(float2ufix64(-INFINITY, 0), 0, "float2ufix645f");
439-
test_checku64(float2ufix64(INFINITY, 16), UINT64_MAX, "float2ufix645");
440-
test_checku64(float2ufix64(-INFINITY, 16), 0, "float2ufix645b");
441439
test_checku64(float2ufix64(3.24999f, 2), 12, "float2ufix646");
442440
test_checku64(float2ufix64(3.25f, 2), 13, "float2ufix647");
443441
test_checku64(float2ufix64(3.0f, -1), 1, "float2ufix648"); // not very useful
@@ -748,7 +746,7 @@ int test() {
748746
test_checki(call_float2int_z(make_negative_denormal_float()), 0, "call_float2int_z13");
749747
#endif
750748

751-
printf("float2uint_z\n");
749+
printf("float2uint_z\n");
752750
test_checku(float2uint_z(0.0f), 0, "float2uint_z1");
753751
test_checku(float2uint_z(0.25f), 0, "float2uint_z2");
754752
test_checku(float2uint_z(0.5f), 0, "float2uint_z3");

0 commit comments

Comments
 (0)