Mercurial > hg > octave-lojdl > gnulib-hg
comparison tests/test-strtod.c @ 9846:25b01b718f02
Don't compare actual signbit return values.
* tests/test-strtod.c (main): Rather, compare only their
zero/non-zero nature.
author | Jim Meyering <meyering@redhat.com> |
---|---|
date | Mon, 31 Mar 2008 19:22:06 +0200 |
parents | a95dd6984607 |
children | bb111aa32127 |
comparison
equal
deleted
inserted
replaced
9845:7898b15f2c3f | 9846:25b01b718f02 |
---|---|
278 errno = 0; | 278 errno = 0; |
279 const char input[] = "-0"; | 279 const char input[] = "-0"; |
280 char *ptr; | 280 char *ptr; |
281 double result = strtod (input, &ptr); | 281 double result = strtod (input, &ptr); |
282 ASSERT (result == 0.0); | 282 ASSERT (result == 0.0); |
283 ASSERT (signbit (result) == signbit (-0.0)); /* IRIX 6.5 */ | 283 ASSERT (!!signbit (result) == !!signbit (-0.0)); /* IRIX 6.5 */ |
284 ASSERT (ptr == input + 2); | 284 ASSERT (ptr == input + 2); |
285 ASSERT (errno == 0); | 285 ASSERT (errno == 0); |
286 } | 286 } |
287 | 287 |
288 /* Suffixes. */ | 288 /* Suffixes. */ |
364 errno = 0; | 364 errno = 0; |
365 const char input[] = "-0x"; | 365 const char input[] = "-0x"; |
366 char *ptr; | 366 char *ptr; |
367 double result = strtod (input, &ptr); | 367 double result = strtod (input, &ptr); |
368 ASSERT (result == 0.0); | 368 ASSERT (result == 0.0); |
369 ASSERT (signbit (result) == signbit (-0.0)); /* MacOS X 10.3, FreeBSD 6.2, IRIX 6.5 */ | 369 ASSERT (!!signbit (result) == !!signbit (-0.0)); /* MacOS X 10.3, FreeBSD 6.2, IRIX 6.5 */ |
370 ASSERT (ptr == input + 2); /* glibc-2.3.6, MacOS X 10.3, FreeBSD 6.2 */ | 370 ASSERT (ptr == input + 2); /* glibc-2.3.6, MacOS X 10.3, FreeBSD 6.2 */ |
371 ASSERT (errno == 0); | 371 ASSERT (errno == 0); |
372 } | 372 } |
373 { | 373 { |
374 errno = 0; | 374 errno = 0; |
478 #if 0 | 478 #if 0 |
479 /* FIXME - this is glibc bug 5995; POSIX allows returning positive | 479 /* FIXME - this is glibc bug 5995; POSIX allows returning positive |
480 0 on negative underflow, even though quality of implementation | 480 0 on negative underflow, even though quality of implementation |
481 demands preserving the sign. Disable this test until fixed | 481 demands preserving the sign. Disable this test until fixed |
482 glibc is more prevalent. */ | 482 glibc is more prevalent. */ |
483 ASSERT (signbit (result) == signbit (-0.0)); /* glibc-2.3.6, mingw */ | 483 ASSERT (!!signbit (result) == !!signbit (-0.0)); /* glibc-2.3.6, mingw */ |
484 #endif | 484 #endif |
485 ASSERT (ptr == input + 10); | 485 ASSERT (ptr == input + 10); |
486 ASSERT (errno == ERANGE); | 486 ASSERT (errno == ERANGE); |
487 } | 487 } |
488 | 488 |
546 ASSERT (isnan (result1)); /* OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, mingw */ | 546 ASSERT (isnan (result1)); /* OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, mingw */ |
547 ASSERT (isnan (result2)); /* OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, mingw */ | 547 ASSERT (isnan (result2)); /* OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, mingw */ |
548 # if 0 | 548 # if 0 |
549 /* Sign bits of NaN is a portability sticking point, not worth | 549 /* Sign bits of NaN is a portability sticking point, not worth |
550 worrying about. */ | 550 worrying about. */ |
551 ASSERT (signbit (result1) != signbit (result2)); /* glibc-2.3.6, IRIX 6.5, OSF/1 5.1, mingw */ | 551 ASSERT (!!signbit (result1) != !!signbit (result2)); /* glibc-2.3.6, IRIX 6.5, OSF/1 5.1, mingw */ |
552 # endif | 552 # endif |
553 ASSERT (ptr1 == input + 4); /* OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, Solaris 2.5.1, mingw */ | 553 ASSERT (ptr1 == input + 4); /* OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, Solaris 2.5.1, mingw */ |
554 ASSERT (ptr2 == input + 4); /* OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, Solaris 2.5.1, mingw */ | 554 ASSERT (ptr2 == input + 4); /* OpenBSD 4.0, IRIX 6.5, OSF/1 5.1, Solaris 2.5.1, mingw */ |
555 ASSERT (errno == 0); /* HP-UX 11.11 */ | 555 ASSERT (errno == 0); /* HP-UX 11.11 */ |
556 #else | 556 #else |
571 double result1 = strtod (input, &ptr1); | 571 double result1 = strtod (input, &ptr1); |
572 double result2 = strtod (input + 1, &ptr2); | 572 double result2 = strtod (input + 1, &ptr2); |
573 #ifdef NAN | 573 #ifdef NAN |
574 ASSERT (isnan (result1)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ | 574 ASSERT (isnan (result1)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ |
575 ASSERT (isnan (result2)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ | 575 ASSERT (isnan (result2)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ |
576 ASSERT (signbit (result1) == signbit (result2)); | 576 ASSERT (!!signbit (result1) == !!signbit (result2)); |
577 ASSERT (ptr1 == input + 4); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 2.5.1, mingw */ | 577 ASSERT (ptr1 == input + 4); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 2.5.1, mingw */ |
578 ASSERT (ptr2 == input + 4); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 2.5.1, mingw */ | 578 ASSERT (ptr2 == input + 4); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 2.5.1, mingw */ |
579 ASSERT (errno == 0); | 579 ASSERT (errno == 0); |
580 #else | 580 #else |
581 ASSERT (result1 == 0.0); | 581 ASSERT (result1 == 0.0); |
598 ASSERT (isnan (result1)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ | 598 ASSERT (isnan (result1)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ |
599 ASSERT (isnan (result2)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ | 599 ASSERT (isnan (result2)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ |
600 # if 0 | 600 # if 0 |
601 /* Sign bits of NaN is a portability sticking point, not worth | 601 /* Sign bits of NaN is a portability sticking point, not worth |
602 worrying about. */ | 602 worrying about. */ |
603 ASSERT (signbit (result1) != signbit (result2)); /* glibc-2.3.6, IRIX 6.5, OSF/1 5.1, mingw */ | 603 ASSERT (!!signbit (result1) != !!signbit (result2)); /* glibc-2.3.6, IRIX 6.5, OSF/1 5.1, mingw */ |
604 # endif | 604 # endif |
605 ASSERT (ptr1 == input + 6); /* glibc-2.3.6, MacOS X 10.3, FreeBSD 6.2, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ | 605 ASSERT (ptr1 == input + 6); /* glibc-2.3.6, MacOS X 10.3, FreeBSD 6.2, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ |
606 ASSERT (ptr2 == input + 6); /* glibc-2.3.6, MacOS X 10.3, FreeBSD 6.2, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ | 606 ASSERT (ptr2 == input + 6); /* glibc-2.3.6, MacOS X 10.3, FreeBSD 6.2, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ |
607 ASSERT (errno == 0); | 607 ASSERT (errno == 0); |
608 #else | 608 #else |
645 ASSERT (isnan (result1)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ | 645 ASSERT (isnan (result1)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ |
646 ASSERT (isnan (result2)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ | 646 ASSERT (isnan (result2)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ |
647 # if 0 | 647 # if 0 |
648 /* Sign bits of NaN is a portability sticking point, not worth | 648 /* Sign bits of NaN is a portability sticking point, not worth |
649 worrying about. */ | 649 worrying about. */ |
650 ASSERT (signbit (result1) != signbit (result2)); /* glibc-2.3.6, IRIX 6.5, OSF/1 5.1, mingw */ | 650 ASSERT (!!signbit (result1) != !!signbit (result2)); /* glibc-2.3.6, IRIX 6.5, OSF/1 5.1, mingw */ |
651 # endif | 651 # endif |
652 ASSERT (ptr1 == input + 7); /* glibc-2.3.6, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ | 652 ASSERT (ptr1 == input + 7); /* glibc-2.3.6, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ |
653 ASSERT (ptr2 == input + 7); /* glibc-2.3.6, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ | 653 ASSERT (ptr2 == input + 7); /* glibc-2.3.6, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */ |
654 ASSERT (errno == 0); | 654 ASSERT (errno == 0); |
655 #else | 655 #else |
827 input[3] = '1'; | 827 input[3] = '1'; |
828 memset (input + 4, '0', m - 3); | 828 memset (input + 4, '0', m - 3); |
829 input[m] = '\0'; | 829 input[m] = '\0'; |
830 result = strtod (input, &ptr); | 830 result = strtod (input, &ptr); |
831 ASSERT (result == 0.0); | 831 ASSERT (result == 0.0); |
832 ASSERT (signbit (result) == signbit (-0.0)); /* IRIX 6.5 */ | 832 ASSERT (!!signbit (result) == !!signbit (-0.0)); /* IRIX 6.5 */ |
833 ASSERT (ptr == input + m); | 833 ASSERT (ptr == input + m); |
834 ASSERT (errno == 0); | 834 ASSERT (errno == 0); |
835 } | 835 } |
836 free (input); | 836 free (input); |
837 } | 837 } |