From 6350d283ff25cc376bfc6285d2793b2f70fa8f09 Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Thu, 26 Nov 2015 14:34:42 +0000 Subject: [PATCH] Test out freeing on simple cloned objects, do they obey the read-only command? ref #3246 git-svn-id: http://svn.osgeo.org/postgis/trunk@14439 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/cunit/cu_misc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/liblwgeom/cunit/cu_misc.c b/liblwgeom/cunit/cu_misc.c index 832a2614b..11554c39c 100644 --- a/liblwgeom/cunit/cu_misc.c +++ b/liblwgeom/cunit/cu_misc.c @@ -138,6 +138,23 @@ static void test_grid(void) lwgeom_free(geomgrid); } +static void test_clone(void) +{ + static char *wkt = "GEOMETRYCOLLECTION(MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0))),POINT(1 1),LINESTRING(2 3,4 5))"; + LWGEOM *geom1 = lwgeom_from_wkt(wkt, LW_PARSER_CHECK_ALL); + LWGEOM *geom2; + + /* Free in "backwards" order */ + geom2 = lwgeom_clone(geom1); + lwgeom_free(geom1); + lwgeom_free(geom2); + + /* Free in "forewards" order */ + geom1 = lwgeom_from_wkt(wkt, LW_PARSER_CHECK_ALL); + geom2 = lwgeom_clone(geom1); + lwgeom_free(geom2); + lwgeom_free(geom1); +} /* ** Used by the test harness to register the tests in this file. @@ -152,4 +169,5 @@ void misc_suite_setup(void) PG_ADD_TEST(suite, test_misc_area); PG_ADD_TEST(suite, test_misc_wkb); PG_ADD_TEST(suite, test_grid); + PG_ADD_TEST(suite, test_clone); } -- 2.40.0