PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ test_gserialized2_peek_gbox_p_fails_for_unsupported_cases()

static void test_gserialized2_peek_gbox_p_fails_for_unsupported_cases ( void  )
static

Definition at line 413 of file cu_gserialized2.c.

414 {
415  uint32_t i;
416 
417  char *ewkt[] =
418  {
419  "MULTIPOINT ((-76.45402132523 44.225406213532), (-72 33))",
420  "LINESTRING (2.2945672355 48.85822923236, -76.45402132523 44.225406213532, -72 33)",
421  "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532, -72 33))",
422  "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532), (-72 33, -71 32))"
423  };
424 
425  for ( i = 0; i < (sizeof ewkt/sizeof(char*)); i++ )
426  {
427  LWGEOM* geom = lwgeom_from_wkt(ewkt[i], LW_PARSER_CHECK_NONE);
428  GBOX box;
429  gbox_init(&box);
430  lwgeom_drop_bbox(geom);
431 
432  /* Construct a GSERIALIZED* that doesn't have a box, so that we can test the
433  * actual logic of the peek function */
434  size_t expected_size = gserialized2_from_lwgeom_size(geom);
435  GSERIALIZED* gser = lwalloc(expected_size);
436  uint8_t* ptr = (uint8_t*) gser;
437 
438  ptr += 8; // Skip header
439  gserialized2_from_lwgeom_any(geom, ptr);
440  gser->gflags = lwflags_get_g2flags(geom->flags);
441 
442  CU_ASSERT_FALSE(gserialized2_has_bbox(gser));
443  CU_ASSERT_EQUAL(LW_FAILURE, gserialized2_peek_gbox_p(gser, &box));
444 
445  lwgeom_free(geom);
446  lwfree(gser);
447  }
448 }
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition: gbox.c:40
int gserialized2_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Definition: gserialized2.c:360
uint8_t lwflags_get_g2flags(lwflags_t lwflags)
Definition: gserialized2.c:116
static size_t gserialized2_from_lwgeom_any(const LWGEOM *geom, uint8_t *buf)
size_t gserialized2_from_lwgeom_size(const LWGEOM *geom)
Return the memory size a GSERIALIZED will occupy for a given LWGEOM.
Definition: gserialized2.c:774
int gserialized2_has_bbox(const GSERIALIZED *g)
Check if a GSERIALIZED has a bounding box without deserializing first.
Definition: gserialized2.c:146
#define LW_FAILURE
Definition: liblwgeom.h:110
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1138
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2060
void lwgeom_drop_bbox(LWGEOM *lwgeom)
Call this function to drop BBOX and SRID from LWGEOM.
Definition: lwgeom.c:664
void lwfree(void *mem)
Definition: lwutil.c:242
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:905
void * lwalloc(size_t size)
Definition: lwutil.c:227
uint8_t gflags
Definition: liblwgeom.h:432
lwflags_t flags
Definition: liblwgeom.h:447

References LWGEOM::flags, gbox_init(), GSERIALIZED::gflags, gserialized2_from_lwgeom_any(), gserialized2_from_lwgeom_size(), gserialized2_has_bbox(), gserialized2_peek_gbox_p(), LW_FAILURE, LW_PARSER_CHECK_NONE, lwalloc(), lwflags_get_g2flags(), lwfree(), lwgeom_drop_bbox(), lwgeom_free(), and lwgeom_from_wkt().

Referenced by gserialized2_suite_setup().

Here is the call graph for this function:
Here is the caller graph for this function: