PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ test_gserialized1_peek_gbox_p_fails_for_unsupported_cases()

static void test_gserialized1_peek_gbox_p_fails_for_unsupported_cases ( void  )
static

Definition at line 1165 of file cu_gserialized1.c.

1166 {
1167  uint32_t i;
1168 
1169  char *ewkt[] =
1170  {
1171  "MULTIPOINT ((-76.45402132523 44.225406213532), (-72 33))",
1172  "LINESTRING (2.2945672355 48.85822923236, -76.45402132523 44.225406213532, -72 33)",
1173  "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532, -72 33))",
1174  "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532), (-72 33, -71 32))"
1175  };
1176 
1177  for ( i = 0; i < (sizeof ewkt/sizeof(char*)); i++ )
1178  {
1179  LWGEOM* geom = lwgeom_from_wkt(ewkt[i], LW_PARSER_CHECK_NONE);
1180  GBOX box;
1181  gbox_init(&box);
1182  lwgeom_drop_bbox(geom);
1183 
1184  /* Construct a GSERIALIZED* that doesn't have a box, so that we can test the
1185  * actual logic of the peek function */
1186  size_t expected_size = gserialized1_from_lwgeom_size(geom);
1187  GSERIALIZED* gser = lwalloc(expected_size);
1188  uint8_t* ptr = (uint8_t*) gser;
1189 
1190  ptr += 8; // Skip header
1191  gserialized1_from_lwgeom_any(geom, ptr);
1192  gser->gflags = lwflags_get_g1flags(geom->flags);
1193 
1194  CU_ASSERT_FALSE(gserialized1_has_bbox(gser));
1195  CU_ASSERT_EQUAL(LW_FAILURE, gserialized1_peek_gbox_p(gser, &box));
1196 
1197  lwgeom_free(geom);
1198  lwfree(gser);
1199  }
1200 }
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition: gbox.c:40
static size_t gserialized1_from_lwgeom_any(const LWGEOM *geom, uint8_t *buf)
Definition: gserialized1.c:982
int gserialized1_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Definition: gserialized1.c:299
int gserialized1_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
Definition: gserialized1.c:91
size_t gserialized1_from_lwgeom_size(const LWGEOM *geom)
Return the memory size a GSERIALIZED will occupy for a given LWGEOM.
Definition: gserialized1.c:722
uint8_t lwflags_get_g1flags(lwflags_t lwflags)
Definition: gserialized1.c:53
#define LW_FAILURE
Definition: liblwgeom.h:96
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1246
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2149
void lwgeom_drop_bbox(LWGEOM *lwgeom)
Call this function to drop BBOX and SRID from LWGEOM.
Definition: lwgeom.c:710
void lwfree(void *mem)
Definition: lwutil.c:248
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:940
void * lwalloc(size_t size)
Definition: lwutil.c:227
uint8_t gflags
Definition: liblwgeom.h:446
lwflags_t flags
Definition: liblwgeom.h:461

References LWGEOM::flags, gbox_init(), GSERIALIZED::gflags, gserialized1_from_lwgeom_any(), gserialized1_from_lwgeom_size(), gserialized1_has_bbox(), gserialized1_peek_gbox_p(), LW_FAILURE, LW_PARSER_CHECK_NONE, lwalloc(), lwflags_get_g1flags(), lwfree(), lwgeom_drop_bbox(), lwgeom_free(), and lwgeom_from_wkt().

Referenced by gserialized1_suite_setup().

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