PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ test_lwprint_roundtrip()

static void test_lwprint_roundtrip ( void  )
static

Definition at line 514 of file cu_print.c.

515 {
516  /* Test roundtrip with the first value outside the range that's always printed as zero */
517  assert_lwprint_roundtrip(nextafter(FP_TOLERANCE, 1));
518  assert_lwprint_roundtrip(nextafter(-FP_TOLERANCE, -1));
519 
520  /* Test roundtrip in around the switch to scientific notation */
525  assert_lwprint_roundtrip(nextafter(OUT_MAX_DOUBLE, INFINITY));
526  assert_lwprint_roundtrip(nextafter(-OUT_MAX_DOUBLE, -INFINITY));
527 
528  /* Test some numbers */
530  assert_lwprint_roundtrip(0.0000000298023223876953125);
533  assert_lwprint_roundtrip(7000109.9999999990686774253845214843750000000000);
534  assert_lwprint_roundtrip(6917529027641081856.0);
535  assert_lwprint_roundtrip(9e+300);
536  assert_lwprint_roundtrip(-9e+300);
537  assert_lwprint_roundtrip(9.000000000000001e+300);
538  assert_lwprint_roundtrip(-9.000000000000001e+300);
539 
540  /* Even if we write the **same** number differently as the (compiler) input the roundtrip is guaranteed */
541  assert_lwprint_roundtrip(149.57565307617187);
542  assert_lwprint_roundtrip(149.57565307617188);
543  assert_lwprint_roundtrip(-149.57565307617187);
544  assert_lwprint_roundtrip(-149.57565307617188);
545 
546  /* Extremes */
547  assert_lwprint_roundtrip(2.2250738585072014e-308); /* We normalize small numbers to 0 */
548  assert_lwprint_roundtrip(1.7976931348623157e+308);
549  assert_lwprint_roundtrip(2.9802322387695312E-8);
550 
551  /* Special cases */
552  assert_lwprint_roundtrip(-0); /* -0 is considered equal to 0 */
553 
554  /* Disabled because Windows / MinGW doesn't like them (#4735)
555  * assert_lwprint_roundtrip(INFINITY);
556  * assert_lwprint_roundtrip(-INFINITY);
557  */
558 
559  /* nan is never equal to nan
560  * assert_lwprint_roundtrip(NAN);
561  */
562 }
#define assert_lwprint_roundtrip(d)
Definition: cu_print.c:506
#define OUT_MAX_DOUBLE
#define FP_TOLERANCE
Floating point comparators.

References assert_lwprint_roundtrip, FP_TOLERANCE, and OUT_MAX_DOUBLE.

Referenced by print_suite_setup().

Here is the caller graph for this function: