PostGIS  3.0.6dev-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 1161 of file cu_gserialized1.c.

1162 {
1163  uint32_t i;
1164 
1165  char *ewkt[] =
1166  {
1167  "MULTIPOINT ((-76.45402132523 44.225406213532), (-72 33))",
1168  "LINESTRING (2.2945672355 48.85822923236, -76.45402132523 44.225406213532, -72 33)",
1169  "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532, -72 33))",
1170  "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532), (-72 33, -71 32))"
1171  };
1172 
1173  for ( i = 0; i < (sizeof ewkt/sizeof(char*)); i++ )
1174  {
1175  LWGEOM* geom = lwgeom_from_wkt(ewkt[i], LW_PARSER_CHECK_NONE);
1176  GBOX box;
1177  gbox_init(&box);
1178  lwgeom_drop_bbox(geom);
1179 
1180  /* Construct a GSERIALIZED* that doesn't have a box, so that we can test the
1181  * actual logic of the peek function */
1182  size_t expected_size = gserialized1_from_lwgeom_size(geom);
1183  GSERIALIZED* gser = lwalloc(expected_size);
1184  uint8_t* ptr = (uint8_t*) gser;
1185 
1186  ptr += 8; // Skip header
1187  gserialized1_from_lwgeom_any(geom, ptr);
1188  gser->gflags = lwflags_get_g1flags(geom->flags);
1189 
1190  CU_ASSERT_FALSE(gserialized1_has_bbox(gser));
1191  CU_ASSERT_EQUAL(LW_FAILURE, gserialized1_peek_gbox_p(gser, &box));
1192 
1193  lwgeom_free(geom);
1194  lwfree(gser);
1195  }
1196 }
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:981
int gserialized1_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Definition: gserialized1.c:298
int gserialized1_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
Definition: gserialized1.c:89
size_t gserialized1_from_lwgeom_size(const LWGEOM *geom)
Return the memory size a GSERIALIZED will occupy for a given LWGEOM.
Definition: gserialized1.c:721
uint8_t lwflags_get_g1flags(lwflags_t lwflags)
Definition: gserialized1.c:51
#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, 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: