PostGIS  2.3.7dev-r@@SVN_REVISION@@
void test_gserialized_peek_gbox_p_fails_for_unsupported_cases ( void  )

Definition at line 1164 of file cu_libgeom.c.

References GSERIALIZED::flags, LWGEOM::flags, gbox_init(), gserialized_from_lwgeom_any(), gserialized_from_lwgeom_size(), gserialized_has_bbox(), gserialized_peek_gbox_p(), LW_FAILURE, LW_PARSER_CHECK_NONE, lwalloc(), lwfree(), lwgeom_drop_bbox(), lwgeom_free(), and lwgeom_from_wkt().

Referenced by libgeom_suite_setup().

1165 {
1166  uint32_t i;
1167 
1168  char *ewkt[] =
1169  {
1170  "MULTIPOINT ((-76.45402132523 44.225406213532), (-72 33))",
1171  "LINESTRING (2.2945672355 48.85822923236, -76.45402132523 44.225406213532, -72 33)",
1172  "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532, -72 33))",
1173  "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532), (-72 33, -71 32))"
1174  };
1175 
1176  for ( i = 0; i < (sizeof ewkt/sizeof(char*)); i++ )
1177  {
1178  LWGEOM* geom = lwgeom_from_wkt(ewkt[i], LW_PARSER_CHECK_NONE);
1179  GBOX box;
1180  gbox_init(&box);
1181  lwgeom_drop_bbox(geom);
1182 
1183  /* Construct a GSERIALIZED* that doesn't have a box, so that we can test the
1184  * actual logic of the peek function */
1185  size_t expected_size = gserialized_from_lwgeom_size(geom);
1186  GSERIALIZED* gser = lwalloc(expected_size);
1187  uint8_t* ptr = (uint8_t*) gser;
1188 
1189  ptr += 8; // Skip header
1190  gserialized_from_lwgeom_any(geom, ptr);
1191  gser->flags = geom->flags;
1192 
1193  CU_ASSERT_FALSE(gserialized_has_bbox(gser));
1194  CU_ASSERT_EQUAL(LW_FAILURE, gserialized_peek_gbox_p(gser, &box));
1195 
1196  lwgeom_free(geom);
1197  lwfree(gser);
1198  }
1199 }
void lwfree(void *mem)
Definition: lwutil.c:242
static int gserialized_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Definition: g_serialized.c:219
uint8_t flags
Definition: liblwgeom.h:396
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1063
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
int gserialized_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
Definition: g_serialized.c:33
void lwgeom_drop_bbox(LWGEOM *lwgeom)
Call this function to drop BBOX and SRID from LWGEOM.
Definition: lwgeom.c:599
#define LW_FAILURE
Definition: liblwgeom.h:78
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1985
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition: g_box.c:51
size_t gserialized_from_lwgeom_size(const LWGEOM *geom)
Calculate required memory segment to contain a serialized form of the LWGEOM.
Definition: g_serialized.c:566
static size_t gserialized_from_lwgeom_any(const LWGEOM *geom, uint8_t *buf)
Definition: g_serialized.c:825
void * lwalloc(size_t size)
Definition: lwutil.c:227
uint8_t flags
Definition: liblwgeom.h:382

Here is the call graph for this function:

Here is the caller graph for this function: