[postgis-tickets] r14787 - fix failing tests on POINT EMPTY, closes #3426

Paul Ramsey pramsey at cleverelephant.ca
Thu Mar 17 09:31:26 PDT 2016


Author: pramsey
Date: 2016-03-17 09:31:26 -0700 (Thu, 17 Mar 2016)
New Revision: 14787

Modified:
   branches/2.2/NEWS
   branches/2.2/liblwgeom/cunit/cu_out_wkb.c
Log:
fix failing tests on POINT EMPTY, closes #3426


Modified: branches/2.2/NEWS
===================================================================
--- branches/2.2/NEWS	2016-03-15 01:08:59 UTC (rev 14786)
+++ branches/2.2/NEWS	2016-03-17 16:31:26 UTC (rev 14787)
@@ -19,6 +19,7 @@
   - #3490, Raster data restore issues, materialized views
   		   Scripts postgis_proc_set_search_path.sql, rtpostgis_proc_set_search_path.sql
   		   refere to http://postgis.net/docs/manual-2.2/RT_FAQ.html#faq_raster_data_not_restore
+  - #3426, failing POINT EMPTY tests on fun architectures
 
 PostGIS 2.2.1
 2016/01/06

Modified: branches/2.2/liblwgeom/cunit/cu_out_wkb.c
===================================================================
--- branches/2.2/liblwgeom/cunit/cu_out_wkb.c	2016-03-15 01:08:59 UTC (rev 14786)
+++ branches/2.2/liblwgeom/cunit/cu_out_wkb.c	2016-03-17 16:31:26 UTC (rev 14787)
@@ -21,6 +21,7 @@
 ** Global variable to hold hex WKB strings
 */
 char *s;
+size_t s_size;
 
 /*
 ** The suite initialization function.
@@ -61,18 +62,20 @@
 {
 	LWGEOM *g = lwgeom_from_wkt(wkt, LW_PARSER_CHECK_NONE);
 	if ( s ) free(s);
-	s = (char*)lwgeom_to_wkb(g, WKB_HEX | WKB_XDR | WKB_EXTENDED, NULL);
+	s = (char*)lwgeom_to_wkb(g, WKB_HEX | WKB_XDR | WKB_EXTENDED, &s_size);
 	lwgeom_free(g);
 }
 
+static void cu_wkb_empty_point_check(char *hex)
+{
+	LWGEOM *g;
+	g = lwgeom_from_hexwkb(hex, LW_PARSER_CHECK_NONE);
+	CU_ASSERT(g != NULL);
+	CU_ASSERT(lwgeom_is_empty(g));
+	CU_ASSERT(g->type == POINTTYPE);
+	lwgeom_free(g);	
+}
 
-/* parisc and mips (at least some processors) have a different nan representation from other arches. */
-#if !defined(__hppa__) && !defined(__mips__)
-# define nan_val( v1, v2)  v1
-#else
-# define nan_val( v1, v2)  v2
-#endif
-
 static void test_wkb_out_point(void)
 {
 	cu_wkb("POINT(0 0 0 0)");
@@ -82,24 +85,19 @@
 	CU_ASSERT_STRING_EQUAL(s,"0060000001000000043FF00000000000003FF00000000000003FF0000000000000");
 	
 	cu_wkb("POINT EMPTY");
-	CU_ASSERT_STRING_EQUAL(s, nan_val("00000000017FF80000000000007FF8000000000000",
-					  "00000000017FF7FFFFFFFFFFFF7FF7FFFFFFFFFFFF"));
-
+	cu_wkb_empty_point_check(s);
+	
 	cu_wkb("SRID=4326;POINT EMPTY");
-	CU_ASSERT_STRING_EQUAL(s, nan_val("0020000001000010E67FF80000000000007FF8000000000000",
-					  "0020000001000010E67FF7FFFFFFFFFFFF7FF7FFFFFFFFFFFF"));
+	cu_wkb_empty_point_check(s);
 
 	cu_wkb("POINT Z EMPTY");
-	CU_ASSERT_STRING_EQUAL(s, nan_val("00800000017FF80000000000007FF80000000000007FF8000000000000",
-					  "00800000017FF7FFFFFFFFFFFF7FF7FFFFFFFFFFFF7FF7FFFFFFFFFFFF"));
+	cu_wkb_empty_point_check(s);
 
 	cu_wkb("POINT M EMPTY");
-	CU_ASSERT_STRING_EQUAL(s, nan_val("00400000017FF80000000000007FF80000000000007FF8000000000000",
-					  "00400000017FF7FFFFFFFFFFFF7FF7FFFFFFFFFFFF7FF7FFFFFFFFFFFF"));
+	cu_wkb_empty_point_check(s);
 
 	cu_wkb("POINT ZM EMPTY");
-	CU_ASSERT_STRING_EQUAL(s, nan_val("00C00000017FF80000000000007FF80000000000007FF80000000000007FF8000000000000",
-					  "00C00000017FF7FFFFFFFFFFFF7FF7FFFFFFFFFFFF7FF7FFFFFFFFFFFF7FF7FFFFFFFFFFFF"));
+	cu_wkb_empty_point_check(s);
 }
 
 static void test_wkb_out_linestring(void)



More information about the postgis-tickets mailing list