Skip to content

Commit 3231269

Browse files
keith-packardnashif
authored andcommitted
tests/c_lib: Skip double sqrt test when double is not 64 bits
This test only works for 64-bit values. On targets which use 32 bits for double, skip this version. The float test will check the 32-bit math for that. This is the 'nicer' version of this fix which uses sizeof rather than relying on __SIZEOF_DOUBLE__. Signed-off-by: Keith Packard <[email protected]>
1 parent 4d8ffcc commit 3231269

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

tests/lib/c_lib/common/src/test_sqrt.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,9 @@ int32_t *p_root_squared = (int32_t *)&root_squared;
149149

150150
ZTEST(libc_common, test_sqrt)
151151
{
152-
#if __SIZEOF_DOUBLE__ != 8
153-
TC_PRINT("test_sqrt skipped, double not 64 bits\n");
154-
ztest_test_skip();
155-
#else
152+
if (sizeof(double) != 8) {
153+
ztest_test_skip();
154+
}
156155
int i;
157156
double resd, error, square, root_squared, exponent;
158157
uint64_t max_error;
@@ -208,5 +207,4 @@ int64_t *p_root_squared = (int64_t *)&root_squared;
208207
zassert_true(max_error < 0x04, "huge errors in sqrt implementation");
209208
/* print the max error */
210209
TC_PRINT("test_sqrt max error %d counts\n", (uint32_t)max_error);
211-
#endif
212210
}

0 commit comments

Comments
 (0)