postgis/loader/cunit/cu_shp2pgsql.c
Mark Cave-Ayland baeeefeb22 Update loader regression test suite to add a simple test for shp2pgsql (much as we now do for pgsql2shp).
Note that these tests aren't completely comprehensive and should be expanded, with the long term aim
of moving the loader regression tests out of the main regression harness and into CUnit instead.

git-svn-id: http://svn.osgeo.org/postgis/trunk@7551 b70326c6-7e19-0410-871a-916f4a2858ee
2011-07-02 13:43:35 +00:00

79 lines
1.8 KiB
C

/**********************************************************************
* $Id: cu_shp2pgsql.c 5674 2010-06-03 02:04:15Z mleslie $
*
* PostGIS - Spatial Types for PostgreSQL
* http://postgis.refractions.net
* Copyright 2010 LISAsoft Pty Ltd
*
* 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 "cu_shp2pgsql.h"
#include "cu_tester.h"
#include "../shp2pgsql-core.h"
/* Test functions */
void test_ShpLoaderCreate(void);
void test_ShpLoaderDestroy(void);
SHPLOADERCONFIG *loader_config;
SHPLOADERSTATE *loader_state;
/*
** Called from test harness to register the tests in this file.
*/
CU_pSuite register_shp2pgsql_suite(void)
{
CU_pSuite pSuite;
pSuite = CU_add_suite("Shapefile Loader File shp2pgsql Test", init_shp2pgsql_suite, clean_shp2pgsql_suite);
if (NULL == pSuite)
{
CU_cleanup_registry();
return NULL;
}
if (
(NULL == CU_add_test(pSuite, "test_ShpLoaderCreate()", test_ShpLoaderCreate)) ||
(NULL == CU_add_test(pSuite, "test_ShpLoaderDestroy()", test_ShpLoaderDestroy))
)
{
CU_cleanup_registry();
return NULL;
}
return pSuite;
}
/*
** The suite initialization function.
** Create any re-used objects.
*/
int init_shp2pgsql_suite(void)
{
return 0;
}
/*
** The suite cleanup function.
** Frees any global objects.
*/
int clean_shp2pgsql_suite(void)
{
return 0;
}
void test_ShpLoaderCreate(void)
{
loader_config = (SHPLOADERCONFIG*)calloc(1, sizeof(SHPLOADERCONFIG));
set_loader_config_defaults(loader_config);
loader_state = ShpLoaderCreate(loader_config);
CU_ASSERT_PTR_NOT_NULL(loader_state);
CU_ASSERT_STRING_EQUAL(loader_state->config->encoding, ENCODING_DEFAULT);
}
void test_ShpLoaderDestroy(void)
{
ShpLoaderDestroy(loader_state);
}