16 #include "CUnit/Basic.h"
21 static void do_test_chaikin(
char *geom_txt,
char *expected,
int n_iterations,
int preserve_end_points)
23 LWGEOM *geom_in, *geom_out;
26 geom_out =
lwgeom_chaikin(geom_in, n_iterations, preserve_end_points);
28 if(strcmp(expected, out_txt))
29 printf(
"%s is not equal to %s\n", expected, out_txt);
30 CU_ASSERT_STRING_EQUAL(expected, out_txt)
40 do_test_chaikin(
"LINESTRING(0 0,8 8,16 0)",
"LINESTRING(0 0,6 6,10 6,16 0)", 1, 1);
42 do_test_chaikin(
"LINESTRING(0 0,8 8,16 0)",
"LINESTRING(0 0,4.5 4.5,7 6,9 6,11.5 4.5,16 0)", 2, 1);
44 do_test_chaikin(
"LINESTRING(0 0,8 8,16 0)",
"LINESTRING(0 0,4.5 4.5,7 6,9 6,11.5 4.5,16 0)", 2, 0);
51 do_test_chaikin(
"POLYGON((0 0,8 8,16 0,0 0))",
"POLYGON((0 0,6 6,10 6,14 2,12 0,0 0))", 1, 1);
53 do_test_chaikin(
"POLYGON((0 0,8 8,16 0,0 0))",
"POLYGON((0 0,4.5 4.5,7 6,9 6,11 5,13 3,13.5 1.5,12.5 0.5,9 0,0 0))", 2, 1);
55 do_test_chaikin(
"POLYGON((0 0,8 8,16 0,0 0))",
"POLYGON((3 3,5 5,7 6,9 6,11 5,13 3,13.5 1.5,12.5 0.5,10 0,6 0,3.5 0.5,2.5 1.5,3 3))", 2, 0);
63 CU_pSuite suite = CU_add_suite(
"chaikin",NULL,NULL);
void chaikin_suite_setup(void)
static void do_test_chaikin(char *geom_txt, char *expected, int n_iterations, int preserve_end_points)
static void do_test_chaikin_lines(void)
static void do_test_chaikin_polygons(void)
#define PG_ADD_TEST(suite, testfunc)
void lwgeom_free(LWGEOM *geom)
#define LW_PARSER_CHECK_NONE
LWGEOM * lwgeom_chaikin(const LWGEOM *igeom, int n_iterations, int preserve_endpoint)
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)