]> granicus.if.org Git - postgis/commitdiff
Made unit tests easier to add. New suites now just need to be added to two lines...
authorPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 23 Feb 2010 22:07:14 +0000 (22:07 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Tue, 23 Feb 2010 22:07:14 +0000 (22:07 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@5329 b70326c6-7e19-0410-871a-916f4a2858ee

24 files changed:
liblwgeom/cunit/cu_algorithm.c
liblwgeom/cunit/cu_algorithm.h [deleted file]
liblwgeom/cunit/cu_geodetic.c
liblwgeom/cunit/cu_geodetic.h [deleted file]
liblwgeom/cunit/cu_homogenize.c
liblwgeom/cunit/cu_homogenize.h [deleted file]
liblwgeom/cunit/cu_libgeom.c
liblwgeom/cunit/cu_libgeom.h [deleted file]
liblwgeom/cunit/cu_measures.c
liblwgeom/cunit/cu_measures.h [deleted file]
liblwgeom/cunit/cu_out_geojson.c
liblwgeom/cunit/cu_out_geojson.h [deleted file]
liblwgeom/cunit/cu_out_gml.c
liblwgeom/cunit/cu_out_gml.h [deleted file]
liblwgeom/cunit/cu_out_kml.c
liblwgeom/cunit/cu_out_kml.h [deleted file]
liblwgeom/cunit/cu_out_svg.c
liblwgeom/cunit/cu_out_svg.h [deleted file]
liblwgeom/cunit/cu_print.c
liblwgeom/cunit/cu_print.h [deleted file]
liblwgeom/cunit/cu_tester.c
liblwgeom/cunit/cu_tester.h
liblwgeom/cunit/cu_wkt.c
liblwgeom/cunit/cu_wkt.h [deleted file]

index fafa50bcd524cf93ddc59ee9bc5fbb8dc2b22c83..2be14ea7e7ed61292fc870ddd9f0d213e5de84c5 100644 (file)
  *
  **********************************************************************/
 
-#include "cu_algorithm.h"
-
-/*
-** Called from test harness to register the tests in this file.
-*/
-CU_pSuite register_cg_suite(void)
-{
-       CU_pSuite pSuite;
-       pSuite = CU_add_suite("PostGIS Computational Geometry Suite", init_cg_suite, clean_cg_suite);
-       if (NULL == pSuite)
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-
-       if (
-           (NULL == CU_add_test(pSuite, "test_lw_segment_side()", test_lw_segment_side)) ||
-           (NULL == CU_add_test(pSuite, "test_lw_segment_intersects()", test_lw_segment_intersects)) ||
-           (NULL == CU_add_test(pSuite, "test_lwline_crossing_short_lines()", test_lwline_crossing_short_lines)) ||
-           (NULL == CU_add_test(pSuite, "test_lwline_crossing_long_lines()", test_lwline_crossing_long_lines)) ||
-           (NULL == CU_add_test(pSuite, "test_lwline_crossing_bugs()", test_lwline_crossing_bugs)) ||
-           (NULL == CU_add_test(pSuite, "test_lwpoint_set_ordinate()", test_lwpoint_set_ordinate)) ||
-           (NULL == CU_add_test(pSuite, "test_lwpoint_get_ordinate()", test_lwpoint_get_ordinate)) ||
-           (NULL == CU_add_test(pSuite, "test_lwpoint_interpolate()", test_lwpoint_interpolate)) ||
-           (NULL == CU_add_test(pSuite, "test_lwline_clip()", test_lwline_clip)) ||
-           (NULL == CU_add_test(pSuite, "test_lwline_clip_big()", test_lwline_clip_big)) ||
-           (NULL == CU_add_test(pSuite, "test_lwmline_clip()", test_lwmline_clip)) ||
-           (NULL == CU_add_test(pSuite, "test_geohash_point()", test_geohash_point)) ||
-           (NULL == CU_add_test(pSuite, "test_geohash_precision()", test_geohash_precision)) ||
-           (NULL == CU_add_test(pSuite, "test_geohash()", test_geohash))
-       )
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-       return pSuite;
-}
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "CUnit/Basic.h"
 
+#include "lwalgorithm.h"
+#include "cu_tester.h"
 
 /*
 ** Global variables used by tests below
@@ -805,3 +774,24 @@ void test_geohash(void)
 }
 
 
+/*
+** Used by test harness to register the tests in this file.
+*/
+CU_TestInfo algorithms_tests[] = {
+       PG_TEST(test_lw_segment_side),
+       PG_TEST(test_lw_segment_intersects),
+       PG_TEST(test_lwline_crossing_short_lines),
+       PG_TEST(test_lwline_crossing_long_lines),
+       PG_TEST(test_lwline_crossing_bugs),
+       PG_TEST(test_lwpoint_set_ordinate),
+       PG_TEST(test_lwpoint_get_ordinate),
+       PG_TEST(test_lwpoint_interpolate),
+       PG_TEST(test_lwline_clip),
+       PG_TEST(test_lwline_clip_big),
+       PG_TEST(test_lwmline_clip),
+       PG_TEST(test_geohash_point),
+       PG_TEST(test_geohash_precision),
+       PG_TEST(test_geohash),
+       CU_TEST_INFO_NULL
+};
+CU_SuiteInfo algorithms_suite = {"PostGIS Computational Geometry Suite",  init_cg_suite,  clean_cg_suite, algorithms_tests};
diff --git a/liblwgeom/cunit/cu_algorithm.h b/liblwgeom/cunit/cu_algorithm.h
deleted file mode 100644 (file)
index 4d05d67..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/**********************************************************************
- * $Id$
- *
- * PostGIS - Spatial Types for PostgreSQL
- * http://postgis.refractions.net
- * Copyright 2008 Paul Ramsey
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU General Public Licence. See the COPYING file.
- *
- **********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "CUnit/Basic.h"
-
-#include "lwalgorithm.h"
-#include "cu_tester.h"
-
-/***********************************************************************
-** for Computational Geometry Suite
-*/
-
-/* Test functions */
-void test_lw_segment_side(void);
-void test_lw_segment_intersects(void);
-void test_lwline_crossing_short_lines(void);
-void test_lwline_crossing_long_lines(void);
-void test_lwpoint_set_ordinate(void);
-void test_lwpoint_get_ordinate(void);
-void test_lwpoint_interpolate(void);
-void test_lwline_clip(void);
-void test_lwline_clip_big(void);
-void test_lwmline_clip(void);
-void test_geohash_precision(void);
-void test_geohash_point(void);
-void test_geohash(void);
-void test_lwline_crossing_bugs(void);
index 49424e1fcb2c7c19b45579e72f68270f1804bb2a..543dc4ae71c262c9baa29d706be9116e3706cf79 100644 (file)
  *
  **********************************************************************/
 
-#include "cu_geodetic.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "CUnit/Basic.h"
 
-#define RANDOM_TEST 0
-
-/*
-** Called from test harness to register the tests in this file.
-*/
-CU_pSuite register_geodetic_suite(void)
-{
-       CU_pSuite pSuite;
-       pSuite = CU_add_suite("Geodetic Suite", init_geodetic_suite, clean_geodetic_suite);
-       if (NULL == pSuite)
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-
-       if (
-           (NULL == CU_add_test(pSuite, "test_signum()", test_signum))  ||
-           (NULL == CU_add_test(pSuite, "test_gbox_from_spherical_coordinates()", test_gbox_from_spherical_coordinates))  ||
-           (NULL == CU_add_test(pSuite, "test_gserialized_get_gbox_geocentric()", test_gserialized_get_gbox_geocentric))  ||
-           (NULL == CU_add_test(pSuite, "test_clairaut()", test_clairaut))  ||
-           (NULL == CU_add_test(pSuite, "test_edge_intersection()", test_edge_intersection))  ||
-           (NULL == CU_add_test(pSuite, "test_edge_distance_to_point()", test_edge_distance_to_point)) ||
-           (NULL == CU_add_test(pSuite, "test_edge_distance_to_edge()", test_edge_distance_to_edge)) ||
-           (NULL == CU_add_test(pSuite, "test_lwgeom_distance_sphere()", test_lwgeom_distance_sphere)) ||
-           (NULL == CU_add_test(pSuite, "test_lwgeom_check_geodetic()", test_lwgeom_check_geodetic)) ||
-           (NULL == CU_add_test(pSuite, "test_gbox_calculation()", test_gbox_calculation)) ||
-           (NULL == CU_add_test(pSuite, "test_gserialized_from_lwgeom()", test_gserialized_from_lwgeom)) ||
-           (NULL == CU_add_test(pSuite, "test_spheroid_distance()", test_spheroid_distance)) ||
-           (NULL == CU_add_test(pSuite, "test_spheroid_area()", test_spheroid_area)) ||
-           (NULL == CU_add_test(pSuite, "test_lwpoly_covers_point2d()", test_lwpoly_covers_point2d)) ||
-           (NULL == CU_add_test(pSuite, "test_ptarray_point_in_ring()", test_ptarray_point_in_ring))
-       )
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-       return pSuite;
-}
-
-/*
-** The suite initialization function.
-** Create any re-used objects.
-*/
-int init_geodetic_suite(void)
-{
-       return 0;
-}
-
-/*
-** The suite cleanup function.
-** Frees any global objects.
-*/
-int clean_geodetic_suite(void)
-{
-       return 0;
-}
+#include "lwgeodetic.h"
+#include "cu_tester.h"
 
+#define RANDOM_TEST 0
 
 /**
 * Convert an edge from degrees to radians.
@@ -982,3 +932,26 @@ void test_spheroid_area(void)
 
 }
 
+
+/*
+** Used by test harness to register the tests in this file.
+*/
+CU_TestInfo geodetic_tests[] = {
+       PG_TEST(test_signum),
+       PG_TEST(test_gbox_from_spherical_coordinates),
+       PG_TEST(test_gserialized_get_gbox_geocentric),
+       PG_TEST(test_clairaut),
+       PG_TEST(test_edge_intersection),
+       PG_TEST(test_edge_distance_to_point),
+       PG_TEST(test_edge_distance_to_edge),
+       PG_TEST(test_lwgeom_distance_sphere),
+       PG_TEST(test_lwgeom_check_geodetic),
+       PG_TEST(test_gbox_calculation),
+       PG_TEST(test_gserialized_from_lwgeom),
+       PG_TEST(test_spheroid_distance),
+       PG_TEST(test_spheroid_area),
+       PG_TEST(test_lwpoly_covers_point2d),
+       PG_TEST(test_ptarray_point_in_ring),
+       CU_TEST_INFO_NULL
+};
+CU_SuiteInfo geodetic_suite = {"Geodetic Suite",  NULL,  NULL, geodetic_tests};
diff --git a/liblwgeom/cunit/cu_geodetic.h b/liblwgeom/cunit/cu_geodetic.h
deleted file mode 100644 (file)
index 423df1d..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/**********************************************************************
- * $Id$
- *
- * PostGIS - Spatial Types for PostgreSQL
- * http://postgis.refractions.net
- * Copyright 2009 Paul Ramsey <pramsey@cleverelephant.ca>
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU General Public Licence. See the COPYING file.
- *
- **********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "CUnit/Basic.h"
-
-#include "lwgeodetic.h"
-#include "cu_tester.h"
-
-/***********************************************************************
-** For new geography library lwgeodetic.h
-*/
-
-
-/* Test functions */
-void test_signum(void);
-void test_gbox_from_spherical_coordinates(void);
-void test_gserialized_get_gbox_geocentric(void);
-void test_clairaut(void);
-void test_gbox_calculation(void);
-void test_edge_intersection(void);
-void test_edge_distance_to_point(void);
-void test_edge_distance_to_edge(void);
-void test_ptarray_point_in_ring_winding(void);
-void test_lwgeom_distance_sphere(void);
-void test_ptarray_point_in_ring(void);
-void test_spheroid_distance(void);
-void test_spheroid_area(void);
-void test_lwpoly_covers_point2d(void);
-void test_gbox_calculation(void);
-void test_lwgeom_check_geodetic(void);
-void test_gserialized_from_lwgeom(void);
index 90a97b15a88e4a2cce48cd368a598269bfababab..a75af70fefcd78a13743bcbf80474a492052a43d 100644 (file)
  *
  **********************************************************************/
 
-#include "cu_homogenize.h"
-
-/*
-** Called from test harness to register the tests in this file.
-*/
-CU_pSuite register_homogenize_suite(void)
-{
-       CU_pSuite pSuite;
-       pSuite = CU_add_suite("Homogenize Suite", init_homogenize_suite, clean_homogenize_suite);
-       if (NULL == pSuite)
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-
-       if (    (NULL == CU_add_test(pSuite, "test_coll_point()", test_coll_point)) ||
-               (NULL == CU_add_test(pSuite, "test_coll_line()", test_coll_line))   ||
-               (NULL == CU_add_test(pSuite, "test_coll_poly()", test_coll_poly))   ||
-               (NULL == CU_add_test(pSuite, "test_coll_coll()", test_coll_coll))   ||
-               (NULL == CU_add_test(pSuite, "test_geom()", test_geom))
-          )
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-       return pSuite;
-}
-
-/*
-** The suite initialization function.
-** Create any re-used objects.
-*/
-int init_homogenize_suite(void)
-{
-       return 0;
-}
-
-/*
-** The suite cleanup function.
-** Frees any global objects.
-*/
-int clean_homogenize_suite(void)
-{
-       return 0;
-}
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "CUnit/Basic.h"
 
+#include "libgeom.h"
+#include "cu_tester.h"
 
 static void do_geom_test(char * in, char * out)
 {
@@ -276,3 +237,16 @@ void test_geom(void)
        do_geom_test("POINT(1 2 3 4)",
                     "POINT(1 2 3 4)");
 }
+
+/*
+** Used by test harness to register the tests in this file.
+*/
+CU_TestInfo homogenize_tests[] = {
+       PG_TEST(test_coll_point),
+       PG_TEST(test_coll_line),
+       PG_TEST(test_coll_poly),
+       PG_TEST(test_coll_coll),
+       PG_TEST(test_geom),
+       CU_TEST_INFO_NULL
+};
+CU_SuiteInfo homogenize_suite = {"Homogenize Suite",  NULL,  NULL, homogenize_tests};
diff --git a/liblwgeom/cunit/cu_homogenize.h b/liblwgeom/cunit/cu_homogenize.h
deleted file mode 100644 (file)
index 9ca853f..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/**********************************************************************
- * $Id:$
- *
- * PostGIS - Spatial Types for PostgreSQL
- * http://postgis.refractions.net
- * Copyright 2009 Olivier Courtin <olivier.courtin@oslandia.com>
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU General Public Licence. See the COPYING file.
- *
- **********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "CUnit/Basic.h"
-
-#include "libgeom.h"
-#include "cu_tester.h"
-
-/**********************************************************************/
-
-
-/* Test functions */
-void test_coll_point(void);
-void test_coll_line(void);
-void test_coll_poly(void);
-void test_coll_coll(void);
-void test_geom(void);
index aa0222e45d1e1984bf63137e74f9df15051c2923..814deaf7d06866bea5b414e82341e8b450ffa346 100644 (file)
  *
  **********************************************************************/
 
-#include "cu_libgeom.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "CUnit/Basic.h"
 
-/*
-** Called from test harness to register the tests in this file.
-*/
-CU_pSuite register_libgeom_suite(void)
-{
-       CU_pSuite pSuite;
-       pSuite = CU_add_suite("LibGeom Suite", init_libgeom_suite, clean_libgeom_suite);
-       if (NULL == pSuite)
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-
-       if (
-           (NULL == CU_add_test(pSuite, "test_typmod_macros()", test_typmod_macros)) ||
-           (NULL == CU_add_test(pSuite, "test_flags_macros()", test_flags_macros)) ||
-           (NULL == CU_add_test(pSuite, "test_serialized_srid()", test_serialized_srid)) ||
-           (NULL == CU_add_test(pSuite, "test_gserialized_from_lwgeom_size()", test_gserialized_from_lwgeom_size)) ||
-           (NULL == CU_add_test(pSuite, "test_gbox_serialized_size()", test_gbox_serialized_size)) ||
-           (NULL == CU_add_test(pSuite, "test_lwgeom_from_gserialized()", test_lwgeom_from_gserialized))  ||
-           (NULL == CU_add_test(pSuite, "test_lwgeom_count_vertices()", test_lwgeom_count_vertices))  ||
-           (NULL == CU_add_test(pSuite, "test_on_gser_lwgeom_count_vertices()", test_on_gser_lwgeom_count_vertices))  ||
-           (NULL == CU_add_test(pSuite, "test_geometry_type_from_string()", test_geometry_type_from_string)) ||
-           (NULL == CU_add_test(pSuite, "test_lwcollection_extract()", test_lwcollection_extract)) ||
-           (NULL == CU_add_test(pSuite, "test_lwgeom_free()", test_lwgeom_free))
-
-       )
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-       return pSuite;
-}
-
-/*
-** The suite initialization function.
-** Create any re-used objects.
-*/
-int init_libgeom_suite(void)
-{
-       return 0;
-}
-
-/*
-** The suite cleanup function.
-** Frees any global objects.
-*/
-int clean_libgeom_suite(void)
-{
-       return 0;
-}
+#include "libgeom.h"
+#include "cu_tester.h"
 
 void test_typmod_macros(void)
 {
@@ -371,3 +325,22 @@ void test_lwgeom_free(void)
        lwgeom_free(geom);
 
 }
+
+/*
+** Used by test harness to register the tests in this file.
+*/
+CU_TestInfo libgeom_tests[] = {
+       PG_TEST(test_typmod_macros),
+       PG_TEST(test_flags_macros),
+       PG_TEST(test_serialized_srid),
+       PG_TEST(test_gserialized_from_lwgeom_size),
+       PG_TEST(test_gbox_serialized_size),
+       PG_TEST(test_lwgeom_from_gserialized),
+       PG_TEST(test_lwgeom_count_vertices),
+       PG_TEST(test_on_gser_lwgeom_count_vertices),
+       PG_TEST(test_geometry_type_from_string),
+       PG_TEST(test_lwcollection_extract),
+       PG_TEST(test_lwgeom_free),
+       CU_TEST_INFO_NULL
+};
+CU_SuiteInfo libgeom_suite = {"LibGeom Suite",  NULL,  NULL, libgeom_tests};
diff --git a/liblwgeom/cunit/cu_libgeom.h b/liblwgeom/cunit/cu_libgeom.h
deleted file mode 100644 (file)
index c319384..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/**********************************************************************
- * $Id$
- *
- * PostGIS - Spatial Types for PostgreSQL
- * http://postgis.refractions.net
- * Copyright 2009 Paul Ramsey <pramsey@cleverelephant.ca>
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU General Public Licence. See the COPYING file.
- *
- **********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "CUnit/Basic.h"
-
-#include "libgeom.h"
-#include "cu_tester.h"
-
-/***********************************************************************
-** For new geometry library libgeom.h
-*/
-
-
-/* Test functions */
-void test_typmod_macros(void);
-void test_flags_macros(void);
-void test_serialized_srid(void);
-void test_gserialized_from_lwgeom_size(void);
-void test_lwgeom_from_gserialized(void);
-void test_geometry_type_from_string(void);
-void test_gbox_serialized_size(void);
-void test_lwcollection_extract(void);
-void test_lwgeom_count_vertices(void);
-void test_on_gser_lwgeom_count_vertices(void);
-void test_lwgeom_free(void);
index 16b9a8bb42677e04a72c1401537c15b8aa081dbf..8a913fed103ca522f5d42f9b89a331b5f3cd611b 100644 (file)
  *
  **********************************************************************/
 
-#include "cu_measures.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "CUnit/Basic.h"
 
-/*
-** Called from test harness to register the tests in this file.
-*/
-CU_pSuite register_measures_suite(void)
-{
-       CU_pSuite pSuite;
-       pSuite = CU_add_suite("PostGIS Measures Suite", init_measures_suite, clean_measures_suite);
-       if (NULL == pSuite)
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-
-       if (
-           (NULL == CU_add_test(pSuite, "test_mindistance2d_tolerance()", test_mindistance2d_tolerance)) ||
-           (NULL == CU_add_test(pSuite, "test_rect_tree_contains_point()", test_rect_tree_contains_point)) ||
-           (NULL == CU_add_test(pSuite, "test_rect_tree_intersects_tree()", test_rect_tree_intersects_tree))
-       )
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-       return pSuite;
-}
-
-/*
-** The suite initialization function.
-** Create any re-used objects.
-*/
-int init_measures_suite(void)
-{
-       return 0;
-}
-
-/*
-** The suite cleanup function.
-** Frees any global objects.
-*/
-int clean_measures_suite(void)
-{
-       return 0;
-}
+#include "liblwgeom.h"
+#include "cu_tester.h"
+#include "measures.h"
+#include "lwtree.h"
 
 void test_mindistance2d_tolerance(void)
 {
@@ -359,3 +324,14 @@ void test_rect_tree_intersects_tree(void)
 
 }
 
+
+/*
+** Used by test harness to register the tests in this file.
+*/
+CU_TestInfo measures_tests[] = {
+       PG_TEST(test_mindistance2d_tolerance),
+       PG_TEST(test_rect_tree_contains_point),
+       PG_TEST(test_rect_tree_intersects_tree),
+       CU_TEST_INFO_NULL
+};
+CU_SuiteInfo measures_suite = {"PostGIS Measures Suite",  NULL,  NULL, measures_tests};
diff --git a/liblwgeom/cunit/cu_measures.h b/liblwgeom/cunit/cu_measures.h
deleted file mode 100644 (file)
index 5d9f6e8..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/**********************************************************************
- * $Id$
- *
- * PostGIS - Spatial Types for PostgreSQL
- * http://postgis.refractions.net
- * Copyright 2009 Paul Ramsey <pramsey@cleverelephant.ca>
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU General Public Licence. See the COPYING file.
- *
- **********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "CUnit/Basic.h"
-
-#include "liblwgeom.h"
-#include "cu_tester.h"
-#include "measures.h"
-#include "lwtree.h"
-
-/***********************************************************************
-** for Computational Geometry Suite
-*/
-
-
-
-/* Test functions */
-void test_mindistance2d_tolerance(void);
-void test_rect_tree_contains_point(void);
-void test_rect_tree_intersects_tree(void);
-
index 7ffcf72f2c07e2881fda52640bb4515af5f88fba..0a9e5f3c53cd8ca23a04a2b40c059dcbc6e9896f 100644 (file)
  *
  **********************************************************************/
 
-#include "cu_out_geojson.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "CUnit/Basic.h"
 
-/*
-** Called from test harness to register the tests in this file.
-*/
-CU_pSuite register_out_geojson_suite(void)
-{
-       CU_pSuite pSuite;
-       pSuite = CU_add_suite("GeoJson Out Suite", init_out_geojson_suite, clean_out_geojson_suite);
-       if (NULL == pSuite)
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-
-       if (
-           (NULL == CU_add_test(pSuite, "test_precision()", out_geojson_test_precision)) ||
-           (NULL == CU_add_test(pSuite, "test_dims()", out_geojson_test_dims)) ||
-           (NULL == CU_add_test(pSuite, "test_srid()", out_geojson_test_srid)) ||
-           (NULL == CU_add_test(pSuite, "test_bbox()", out_geojson_test_bbox)) ||
-           (NULL == CU_add_test(pSuite, "test_geoms()", out_geojson_test_geoms))
-       )
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-       return pSuite;
-}
-
-/*
-** The suite initialization function.
-** Create any re-used objects.
-*/
-int init_out_geojson_suite(void)
-{
-       return 0;
-}
-
-/*
-** The suite cleanup function.
-** Frees any global objects.
-*/
-int clean_out_geojson_suite(void)
-{
-       return 0;
-}
+#include "libgeom.h"
+#include "cu_tester.h"
 
 static void do_geojson_test(char * in, char * out, char * srs, int precision, int has_bbox)
 {
@@ -309,3 +270,16 @@ void out_geojson_test_geoms(void)
            "MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0)),((7 8,10 10,6 14,4 11,7 8)))",
            "lwgeom_to_geojson: 'MultiSurface' geometry type not supported");
 }
+
+/*
+** Used by test harness to register the tests in this file.
+*/
+CU_TestInfo out_geojson_tests[] = {
+       PG_TEST(out_geojson_test_precision),
+       PG_TEST(out_geojson_test_dims),
+       PG_TEST(out_geojson_test_srid),
+       PG_TEST(out_geojson_test_bbox),
+       PG_TEST(out_geojson_test_geoms),
+       CU_TEST_INFO_NULL
+};
+CU_SuiteInfo out_geojson_suite = {"GeoJson Out Suite",  NULL,  NULL, out_geojson_tests};
diff --git a/liblwgeom/cunit/cu_out_geojson.h b/liblwgeom/cunit/cu_out_geojson.h
deleted file mode 100644 (file)
index 99c8c12..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/**********************************************************************
- * $Id:$
- *
- * PostGIS - Spatial Types for PostgreSQL
- * http://postgis.refractions.net
- * Copyright 2010 Olivier Courtin <olivier.courtin@oslandia.com>
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU General Public Licence. See the COPYING file.
- *
- **********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "CUnit/Basic.h"
-
-#include "libgeom.h"
-#include "cu_tester.h"
-
-/**********************************************************************/
-
-
-/* Test functions */
-void out_geojson_test_precision(void);
-void out_geojson_test_geoms(void);
-void out_geojson_test_dims(void);
-void out_geojson_test_srid(void);
-void out_geojson_test_bbox(void);
index 6b49f26c57d732a97ad55cebfba9f69b64b06962..f7773b3d90c86eb544dc3285600d581cb319f46f 100644 (file)
  *
  **********************************************************************/
 
-#include "cu_out_gml.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "CUnit/Basic.h"
 
-/*
-** Called from test harness to register the tests in this file.
-*/
-CU_pSuite register_out_gml_suite(void)
-{
-       CU_pSuite pSuite;
-       pSuite = CU_add_suite("GML Out Suite", init_out_gml_suite, clean_out_gml_suite);
-       if (NULL == pSuite)
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-
-       if (
-           (NULL == CU_add_test(pSuite, "test_precision()", out_gml_test_precision)) ||
-           (NULL == CU_add_test(pSuite, "test_srid()", out_gml_test_srid)) ||
-           (NULL == CU_add_test(pSuite, "test_dims()", out_gml_test_dims)) ||
-           (NULL == CU_add_test(pSuite, "test_geodetic()", out_gml_test_geodetic)) ||
-           (NULL == CU_add_test(pSuite, "test_geoms()", out_gml_test_geoms))
-       )
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-       return pSuite;
-}
-
-/*
-** The suite initialization function.
-** Create any re-used objects.
-*/
-int init_out_gml_suite(void)
-{
-       return 0;
-}
-
-/*
-** The suite cleanup function.
-** Frees any global objects.
-*/
-int clean_out_gml_suite(void)
-{
-       return 0;
-}
+#include "libgeom.h"
+#include "cu_tester.h"
 
 static void do_gml2_test(char * in, char * out, char * srs, int precision)
 {
@@ -504,3 +465,16 @@ void out_gml_test_geoms(void)
            "MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0)),((7 8,10 10,6 14,4 11,7 8)))",
            "lwgeom_to_gml3: 'MultiSurface' geometry type not supported");
 }
+
+/*
+** Used by test harness to register the tests in this file.
+*/
+CU_TestInfo out_gml_tests[] = {
+       PG_TEST(out_gml_test_precision),
+       PG_TEST(out_gml_test_srid),
+       PG_TEST(out_gml_test_dims),
+       PG_TEST(out_gml_test_geodetic),
+       PG_TEST(out_gml_test_geoms),
+       CU_TEST_INFO_NULL
+};
+CU_SuiteInfo out_gml_suite = {"GML Out Suite",  NULL,  NULL, out_gml_tests};
diff --git a/liblwgeom/cunit/cu_out_gml.h b/liblwgeom/cunit/cu_out_gml.h
deleted file mode 100644 (file)
index 58c746c..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/**********************************************************************
- * $Id:$
- *
- * PostGIS - Spatial Types for PostgreSQL
- * http://postgis.refractions.net
- * Copyright 2010 Olivier Courtin <olivier.courtin@oslandia.com>
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU General Public Licence. See the COPYING file.
- *
- **********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "CUnit/Basic.h"
-
-#include "libgeom.h"
-#include "cu_tester.h"
-
-/**********************************************************************/
-
-
-/* Test functions */
-void out_gml_test_precision(void);
-void out_gml_test_srid(void);
-void out_gml_test_geodetic(void);
-void out_gml_test_geoms(void);
-void out_gml_test_dims(void);
index b6d2b7081824e369c6a55760124bd80ef2bf93ea..66fc0a6125dfeaf1d368f69e32717b21934501c5 100644 (file)
  *
  **********************************************************************/
 
-#include "cu_out_kml.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "CUnit/Basic.h"
 
-/*
-** Called from test harness to register the tests in this file.
-*/
-CU_pSuite register_out_kml_suite(void)
-{
-       CU_pSuite pSuite;
-       pSuite = CU_add_suite("KML Out Suite", init_out_kml_suite, clean_out_kml_suite);
-       if (NULL == pSuite)
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-
-       if (
-           (NULL == CU_add_test(pSuite, "test_precision()", out_kml_test_precision)) ||
-           (NULL == CU_add_test(pSuite, "test_dims()", out_kml_test_dims)) ||
-           (NULL == CU_add_test(pSuite, "test_geoms()", out_kml_test_geoms))
-       )
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-       return pSuite;
-}
-
-/*
-** The suite initialization function.
-** Create any re-used objects.
-*/
-int init_out_kml_suite(void)
-{
-       return 0;
-}
-
-/*
-** The suite cleanup function.
-** Frees any global objects.
-*/
-int clean_out_kml_suite(void)
-{
-       return 0;
-}
+#include "libgeom.h"
+#include "cu_tester.h"
 
 static void do_kml_test(char * in, char * out, int precision)
 {
@@ -211,3 +174,14 @@ void out_kml_test_geoms(void)
            "MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0)),((7 8,10 10,6 14,4 11,7 8)))",
            "lwgeom_to_kml2: 'MultiSurface' geometry type not supported");
 }
+
+/*
+** Used by test harness to register the tests in this file.
+*/
+CU_TestInfo out_kml_tests[] = {
+       PG_TEST(out_kml_test_precision),
+       PG_TEST(out_kml_test_dims),
+       PG_TEST(out_kml_test_geoms),
+       CU_TEST_INFO_NULL
+};
+CU_SuiteInfo out_kml_suite = {"KML Out Suite",  NULL,  NULL, out_kml_tests};
diff --git a/liblwgeom/cunit/cu_out_kml.h b/liblwgeom/cunit/cu_out_kml.h
deleted file mode 100644 (file)
index 7f33c1c..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/**********************************************************************
- * $Id:$
- *
- * PostGIS - Spatial Types for PostgreSQL
- * http://postgis.refractions.net
- * Copyright 2010 Olivier Courtin <olivier.courtin@oslandia.com>
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU General Public Licence. See the COPYING file.
- *
- **********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "CUnit/Basic.h"
-
-#include "libgeom.h"
-#include "cu_tester.h"
-
-/**********************************************************************/
-
-
-/* Test functions */
-void out_kml_test_precision(void);
-void out_kml_test_geoms(void);
-void out_kml_test_dims(void);
index 3609a0e9465e18f70310b91d5b98c6a8e4a0d5cd..84831f8f2626a3809c89b3119b6925b2be71f1e7 100644 (file)
  *
  **********************************************************************/
 
-#include "cu_out_svg.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "CUnit/Basic.h"
 
-/*
-** Called from test harness to register the tests in this file.
-*/
-CU_pSuite register_out_svg_suite(void)
-{
-       CU_pSuite pSuite;
-       pSuite = CU_add_suite("SVG Out Suite", init_out_svg_suite, clean_out_svg_suite);
-       if (NULL == pSuite)
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-
-       if (
-           (NULL == CU_add_test(pSuite, "test_precision()", out_svg_test_precision)) ||
-           (NULL == CU_add_test(pSuite, "test_dims()", out_svg_test_dims)) ||
-           (NULL == CU_add_test(pSuite, "test_relative()", out_svg_test_relative)) ||
-           (NULL == CU_add_test(pSuite, "test_geoms()", out_svg_test_geoms)) ||
-           (NULL == CU_add_test(pSuite, "test_srid()", out_svg_test_srid))
-       )
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-       return pSuite;
-}
-
-/*
-** The suite initialization function.
-** Create any re-used objects.
-*/
-int init_out_svg_suite(void)
-{
-       return 0;
-}
-
-/*
-** The suite cleanup function.
-** Frees any global objects.
-*/
-int clean_out_svg_suite(void)
-{
-       return 0;
-}
+#include "libgeom.h"
+#include "cu_tester.h"
 
 static void do_svg_test(char * in, char * out, int precision, int relative)
 {
@@ -353,3 +314,16 @@ void out_svg_test_srid(void)
            "M 0 -1 l 2 -2",
            0, 1);
 }
+
+/*
+** Used by test harness to register the tests in this file.
+*/
+CU_TestInfo out_svg_tests[] = {
+       PG_TEST(out_svg_test_precision),
+       PG_TEST(out_svg_test_dims),
+       PG_TEST(out_svg_test_relative),
+       PG_TEST(out_svg_test_geoms),
+       PG_TEST(out_svg_test_srid),
+       CU_TEST_INFO_NULL
+};
+CU_SuiteInfo out_svg_suite = {"SVG Out Suite",  NULL,  NULL, out_svg_tests};
diff --git a/liblwgeom/cunit/cu_out_svg.h b/liblwgeom/cunit/cu_out_svg.h
deleted file mode 100644 (file)
index 21125eb..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/**********************************************************************
- * $Id:$
- *
- * PostGIS - Spatial Types for PostgreSQL
- * http://postgis.refractions.net
- * Copyright 2010 Olivier Courtin <olivier.courtin@oslandia.com>
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU General Public Licence. See the COPYING file.
- *
- **********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "CUnit/Basic.h"
-
-#include "libgeom.h"
-#include "cu_tester.h"
-
-/**********************************************************************/
-
-
-/* Test functions */
-void out_svg_test_precision(void);
-void out_svg_test_geoms(void);
-void out_svg_test_dims(void);
-void out_svg_test_srid(void);
-void out_svg_test_relative(void);
index 0b2f6b813e5bc94be9ba0c40c4ab8cd0a66d2e9b..fb6cb51242a1eb06e4a298a979306c32f5c0be40 100644 (file)
  *
  **********************************************************************/
 
-#include "cu_print.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "CUnit/Basic.h"
 
-/*
-** Called from test harness to register the tests in this file.
-*/
-CU_pSuite register_print_suite(void)
-{
-       CU_pSuite pSuite;
-       pSuite = CU_add_suite("PostGIS Print Suite", init_print_suite, clean_print_suite);
-       if (NULL == pSuite)
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-
-       if (
-           (NULL == CU_add_test(pSuite, "test_lwprint_default_format()", test_lwprint_default_format)) ||
-           (NULL == CU_add_test(pSuite, "test_lwprint_format_order()", test_lwprint_format_order)) ||
-           (NULL == CU_add_test(pSuite, "test_lwprint_format_optional()", test_lwprint_format_optional)) ||
-           (NULL == CU_add_test(pSuite, "test_lwprint_oddball_format()", test_lwprint_oddball_format)) ||
-           (NULL == CU_add_test(pSuite, "test_lwprint_bad_formats()", test_lwprint_bad_formats))
-       )
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-       return pSuite;
-}
-
-
-/*
-** The suite initialization function.
-** Create any re-used objects.
-*/
-int init_print_suite(void)
-{
-       return 0;
-}
+#include "liblwgeom.h"
+#include "cu_tester.h"
 
-/*
-** The suite cleanup function.
-** Frees any global objects.
-*/
-int clean_print_suite(void)
-{
-       return 0;
-}
 
 static void test_lwprint_assert_format(char * point_wkt, const char * format, const char * expected)
 {
@@ -124,7 +85,7 @@ void test_lwprint_default_format(void)
 /*
  * Test all possible combinations of the orders of the parameters.
  */
-void test_lwprint_format_order(void)
+void test_lwprint_format_orders(void)
 {
        test_lwprint_assert_format("POINT(-45.4545 -12.34567)", "C DD MM SS", "S 12 20 44 W 45 27 16");
        test_lwprint_assert_format("POINT(-45.4545 -12.34567)", "C DD SS MM", "S 12 44 20 W 45 16 27");
@@ -158,7 +119,7 @@ void test_lwprint_format_order(void)
 /*
  * Test with and without the optional parameters.
  */
-void test_lwprint_format_optional(void)
+void test_lwprint_optional_format(void)
 {
        test_lwprint_assert_format("POINT(-45.4545 -12.34567)", "DD.DDD", "-12.346 -45.455");
        test_lwprint_assert_format("POINT(-45.4545 -12.34567)", "DD.DDD C", "12.346 S 45.455 W");
@@ -168,7 +129,7 @@ void test_lwprint_format_optional(void)
        test_lwprint_assert_format("POINT(-45.4545 -12.34567)", "DD.DDD MM.MMM SS.SSS C", "12.000 20.000 44.412 S 45.000 27.000 16.200 W");
 }
 
-void test_lwprint_oddball_format(void)
+void test_lwprint_oddball_formats(void)
 {
        test_lwprint_assert_format("POINT(-45.4545 -12.34567)", "DD.DDDMM.MMMSS.SSSC", "12.00020.00044.412S 45.00027.00016.200W");
        test_lwprint_assert_format("POINT(-45.4545 -12.34567)", "DDMM.MMM", "-1220.740 -4527.270");
@@ -195,3 +156,16 @@ void test_lwprint_bad_formats(void)
        test_lwprint_assert_error("POINT(1.23456 7.89012)", "DD.DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD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jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj");
 }
+
+/*
+** Used by the test harness to register the tests in this file.
+*/
+CU_TestInfo print_tests[] = {
+       PG_TEST(test_lwprint_default_format),
+       PG_TEST(test_lwprint_format_orders),
+       PG_TEST(test_lwprint_optional_format),
+       PG_TEST(test_lwprint_oddball_formats),
+       PG_TEST(test_lwprint_bad_formats),
+       CU_TEST_INFO_NULL
+};
+CU_SuiteInfo print_suite = {"print_suite", NULL, NULL, print_tests };
diff --git a/liblwgeom/cunit/cu_print.h b/liblwgeom/cunit/cu_print.h
deleted file mode 100644 (file)
index ed87cd5..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/**********************************************************************
- * $Id: cu_print.h 4786 2009-11-11 19:02:19Z pramsey $
- *
- * PostGIS - Spatial Types for PostgreSQL
- * http://postgis.refractions.net
- * Copyright 2008 Paul Ramsey
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU General Public Licence. See the COPYING file.
- *
- **********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "CUnit/Basic.h"
-
-#include "liblwgeom.h"
-#include "cu_tester.h"
-
-/***********************************************************************
-** for Print Suite
-*/
-
-/* Test functions */
-void test_lwprint_default_format(void);
-void test_lwprint_format_order(void);
-void test_lwprint_format_optional(void);
-void test_lwprint_bad_formats(void);
-void test_lwprint_oddball_format(void);
index b0de2f78fc56a45afb2f56452a2843d47f1d0890..277f06b76c59eca8c0ad6095214c02054e3ecdd7 100644 (file)
 #include "liblwgeom.h"
 #include "cu_tester.h"
 
-
-/**
- * CUnit error handler
- * Log message in a global var instead of printing in stderr
- *
- * CAUTION: Not stop execution on lwerror case !!!
- */
-static void
-cu_errorreporter(const char *fmt, va_list ap)
-{
-       char *msg;
-
-       /** This is a GNU extension.
-       * Dunno how to handle errors here.
-        */
-       if (!lw_vasprintf (&msg, fmt, ap))
-       {
-               va_end (ap);
-               return;
-       }
-
-       strncpy(cu_error_msg, msg, MAX_CUNIT_ERROR_LENGTH);
-}
-
-void
-cu_error_msg_reset()
-{
-       memset(cu_error_msg, '\0', MAX_CUNIT_ERROR_LENGTH);
-}
-
-/*CU_named_suite *
-cu_create_suite(const char *name, CU_InitializeFunc init_func, CU_CleanupFunc clean_func) {
-       CU_pSuite pSuite = CU_add_suite(name, init_func, clean_func);
-       if (NULL == pSuite)
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-       num_suites++;
-}
-void cu_add_named_test(CU_named_suite *nSuite, const char *name, CU_TestFunc test_func) {
-       strcpy(nSuite->tests[nSuite->num_tests].name, name);
-       nSuite->tests[nSuite->num_tests].test_func = CU_add_test(nSuite->cu_suite, name, test_func);
-       if (NULL == nSuite->tests[nSuite->num_tests].test_func) {
-               CU_cleanup_registry();
-               return NULL;
-       }
-       nSuite->num_tests++;
-}*/
-       
-/*
-** Set up liblwgeom to run in stand-alone mode using the
-** usual system memory handling functions.
-*/
-void lwgeom_init_allocators(void)
-{
-       lwalloc_var = default_allocator;
-       lwrealloc_var = default_reallocator;
-       lwfree_var = default_freeor;
-       lwnotice_var = default_noticereporter;
-       lwerror_var = cu_errorreporter;
-}
+/* ADD YOUR SUITE HERE (1 of 2) */
+extern CU_SuiteInfo print_suite;
+extern CU_SuiteInfo algorithms_suite;
+extern CU_SuiteInfo measures_suite;
+extern CU_SuiteInfo wkt_suite;
+extern CU_SuiteInfo libgeom_suite;
+extern CU_SuiteInfo geodetic_suite;
+extern CU_SuiteInfo homogenize_suite;
+extern CU_SuiteInfo out_gml_suite;
+extern CU_SuiteInfo out_kml_suite;
+extern CU_SuiteInfo out_geojson_suite;
+extern CU_SuiteInfo out_svg_suite;
 
 /*
 ** The main() function for setting up and running the tests.
@@ -87,6 +37,22 @@ void lwgeom_init_allocators(void)
 */
 int main(int argc, char *argv[])
 {
+       /* ADD YOUR SUITE HERE (2 of 2) */
+       CU_SuiteInfo suites[] = {
+               print_suite,
+               algorithms_suite,
+               measures_suite,
+               wkt_suite,
+               libgeom_suite,
+               geodetic_suite,
+               homogenize_suite,
+               out_gml_suite,
+               out_kml_suite,
+               out_geojson_suite,
+               out_svg_suite,
+               CU_SUITE_INFO_NULL
+       };
+
        int index;
        char *suite_name;
        CU_pSuite suite_to_run;
@@ -99,84 +65,17 @@ int main(int argc, char *argv[])
        int num_failed;
 
        /* initialize the CUnit test registry */
-       if (CUE_SUCCESS != CU_initialize_registry())
-               return CU_get_error();
-
-       /* Add the algorithms suite to the registry */
-       if (NULL == register_cg_suite())
-       {
-               CU_cleanup_registry();
-               return CU_get_error();
+       if (CUE_SUCCESS != CU_initialize_registry()) {
+               errCode = CU_get_error();
+               printf("    Error attempting to initialize registry: %d.  See CUError.h for error code list.\n", errCode);
+               return errCode;
        }
 
-       /* Add the measures suite to the registry */
-       if (NULL == register_measures_suite())
-       {
-               CU_cleanup_registry();
-               return CU_get_error();
-       }
-
-       /* Add the wkt suite to the registry */
-       if (NULL == register_wkt_suite())
-       {
-               CU_cleanup_registry();
-               return CU_get_error();
-       }
-
-       /* Add the libgeom suite to the registry */
-       if (NULL == register_libgeom_suite())
-       {
-               CU_cleanup_registry();
-               return CU_get_error();
-       }
-
-       /* Add the geodetic suite to the registry */
-       if (NULL == register_geodetic_suite())
-       {
-               CU_cleanup_registry();
-               return CU_get_error();
-       }
-
-       /* Add the print suite to the registry */
-       if (NULL == register_print_suite())
-       {
-               CU_cleanup_registry();
-               return CU_get_error();
-       }
-
-       /* Add the homogenize suite to the registry */
-       if (NULL == register_homogenize_suite())
-       {
-               CU_cleanup_registry();
-               return CU_get_error();
-       }
-
-       /* Add the gml suite to the registry */
-       if (NULL == register_out_gml_suite())
-       {
-               CU_cleanup_registry();
-               return CU_get_error();
-       }
-
-       /* Add the kml suite to the registry */
-       if (NULL == register_out_kml_suite())
-       {
-               CU_cleanup_registry();
-               return CU_get_error();
-       }
-
-       /* Add the geojson suite to the registry */
-       if (NULL == register_out_geojson_suite())
-       {
-               CU_cleanup_registry();
-               return CU_get_error();
-       }
-
-       /* Add the svg suite to the registry */
-       if (NULL == register_out_svg_suite())
-       {
-               CU_cleanup_registry();
-               return CU_get_error();
+       /* Register all the test suites. */
+       if (CUE_SUCCESS != CU_register_suites(suites)) {
+               errCode = CU_get_error();
+               printf("    Error attempting to register test suites: %d.  See CUError.h for error code list.\n", errCode);
+               return errCode;
        }
 
        /* Run all tests using the CUnit Basic interface */
@@ -253,3 +152,45 @@ int main(int argc, char *argv[])
        CU_cleanup_registry();
        return CU_get_error();
 }
+/**
+ * CUnit error handler
+ * Log message in a global var instead of printing in stderr
+ *
+ * CAUTION: Not stop execution on lwerror case !!!
+ */
+static void
+cu_errorreporter(const char *fmt, va_list ap)
+{
+       char *msg;
+
+       /** This is a GNU extension.
+       * Dunno how to handle errors here.
+        */
+       if (!lw_vasprintf (&msg, fmt, ap))
+       {
+               va_end (ap);
+               return;
+       }
+
+       strncpy(cu_error_msg, msg, MAX_CUNIT_ERROR_LENGTH);
+}
+
+void
+cu_error_msg_reset()
+{
+       memset(cu_error_msg, '\0', MAX_CUNIT_ERROR_LENGTH);
+}
+
+/*
+** Set up liblwgeom to run in stand-alone mode using the
+** usual system memory handling functions.
+*/
+void lwgeom_init_allocators(void)
+{
+       lwalloc_var = default_allocator;
+       lwrealloc_var = default_reallocator;
+       lwfree_var = default_freeor;
+       lwnotice_var = default_noticereporter;
+       lwerror_var = cu_errorreporter;
+}
+
index 04629068bb94a9c2b4fa3ec7d88d424cb9b4863e..ab0058b1261e753bb506f24ccbf0f03920d2c46f 100644 (file)
@@ -1,40 +1,5 @@
+#define PG_TEST(test_func) { #test_func, test_func }
 #define MAX_CUNIT_ERROR_LENGTH 512
 char cu_error_msg[MAX_CUNIT_ERROR_LENGTH+1];
 void cu_error_msg_reset();
 
-CU_pSuite register_measures_suite(void);
-CU_pSuite register_geodetic_suite(void);
-CU_pSuite register_libgeom_suite(void);
-CU_pSuite register_cg_suite(void);
-CU_pSuite register_print_suite(void);
-CU_pSuite register_wkt_suite(void);
-CU_pSuite register_homogenize_suite(void);
-CU_pSuite register_out_gml_suite(void);
-CU_pSuite register_out_kml_suite(void);
-CU_pSuite register_out_geojson_suite(void);
-CU_pSuite register_out_svg_suite(void);
-
-int init_measures_suite(void);
-int init_geodetic_suite(void);
-int init_libgeom_suite(void);
-int init_cg_suite(void);
-int init_print_suite(void);
-int init_wkt_suite(void);
-int init_homogenize_suite(void);
-int init_out_gml_suite(void);
-int init_out_kml_suite(void);
-int init_out_geojson_suite(void);
-int init_out_svg_suite(void);
-
-int clean_measures_suite(void);
-int clean_geodetic_suite(void);
-int clean_libgeom_suite(void);
-int clean_cg_suite(void);
-int clean_print_suite(void);
-int clean_wkt_suite(void);
-int clean_homogenize_suite(void);
-int clean_out_gml_suite(void);
-int clean_out_kml_suite(void);
-int clean_out_geojson_suite(void);
-int clean_out_svg_suite(void);
-
index 8f6617e8e1f5de360eeb22d84f6edb2de5242695..f1f9bbea99975ef43c1861596af006e7da3dbb54 100644 (file)
  *
  **********************************************************************/
 
-#include "cu_wkt.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "CUnit/Basic.h"
 
-/*
-** Called from test harness to register the tests in this file.
-*/
-CU_pSuite register_wkt_suite(void)
-{
-       CU_pSuite pSuite;
-       pSuite = CU_add_suite("WKT Suite", init_wkt_suite, clean_wkt_suite);
-       if (NULL == pSuite)
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-
-       if (
-           (NULL == CU_add_test(pSuite, "test_wkt_point()", test_wkt_point)) ||
-           (NULL == CU_add_test(pSuite, "test_wkt_linestring()", test_wkt_linestring)) ||
-           (NULL == CU_add_test(pSuite, "test_wkt_polygon()", test_wkt_polygon)) ||
-           (NULL == CU_add_test(pSuite, "test_wkt_multipoint()", test_wkt_multipoint)) ||
-           (NULL == CU_add_test(pSuite, "test_wkt_multilinestring()", test_wkt_multilinestring)) ||
-           (NULL == CU_add_test(pSuite, "test_wkt_multipolygon()", test_wkt_multipolygon)) ||
-           (NULL == CU_add_test(pSuite, "test_wkt_collection()", test_wkt_collection)) ||
-           (NULL == CU_add_test(pSuite, "test_wkt_circularstring()", test_wkt_circularstring)) ||
-           (NULL == CU_add_test(pSuite, "test_wkt_compoundcurve()", test_wkt_compoundcurve)) ||
-           (NULL == CU_add_test(pSuite, "test_wkt_curvpolygon()", test_wkt_curvpolygon)) || 
-           (NULL == CU_add_test(pSuite, "test_wkt_multicurve()", test_wkt_multicurve)) ||
-           (NULL == CU_add_test(pSuite, "test_wkt_multisurface()", test_wkt_multisurface)) 
-       )
-       {
-               CU_cleanup_registry();
-               return NULL;
-       }
-       return pSuite;
-}
+#include "libgeom.h"
+#include "cu_tester.h"
 
 /*
 ** Global variable to hold WKT strings
@@ -201,3 +173,22 @@ void test_wkt_multisurface(void)
        
 }
 
+/*
+** Used by test harness to register the tests in this file.
+*/
+CU_TestInfo wkt_tests[] = {
+       PG_TEST(test_wkt_point),
+       PG_TEST(test_wkt_linestring),
+       PG_TEST(test_wkt_polygon),
+       PG_TEST(test_wkt_multipoint),
+       PG_TEST(test_wkt_multilinestring),
+       PG_TEST(test_wkt_multipolygon),
+       PG_TEST(test_wkt_collection),
+       PG_TEST(test_wkt_circularstring),
+       PG_TEST(test_wkt_compoundcurve),
+       PG_TEST(test_wkt_curvpolygon),
+       PG_TEST(test_wkt_multicurve),
+       PG_TEST(test_wkt_multisurface),
+       CU_TEST_INFO_NULL
+};
+CU_SuiteInfo wkt_suite = {"WKT Suite",  init_wkt_suite,  clean_wkt_suite, wkt_tests};
diff --git a/liblwgeom/cunit/cu_wkt.h b/liblwgeom/cunit/cu_wkt.h
deleted file mode 100644 (file)
index ee16ccc..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/**********************************************************************
- * $Id:$
- *
- * PostGIS - Spatial Types for PostgreSQL
- * http://postgis.refractions.net
- * Copyright 2010 Olivier Courtin <olivier.courtin@oslandia.com>
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU General Public Licence. See the COPYING file.
- *
- **********************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "CUnit/Basic.h"
-
-#include "libgeom.h"
-#include "cu_tester.h"
-
-/**********************************************************************/
-
-
-/* Test functions */
-void test_wkt_point(void);
-void test_wkt_linestring(void);
-void test_wkt_polygon(void);
-void test_wkt_multipoint(void);
-void test_wkt_multilinestring(void);
-void test_wkt_multipolygon(void);
-void test_wkt_collection(void);
-void test_wkt_circularstring(void);
-void test_wkt_compoundcurve(void);
-void test_wkt_curvpolygon(void);
-void test_wkt_multicurve(void);
-void test_wkt_multisurface(void);