diff --git a/Modules/Adapters/GdalAdapters/test/CMakeLists.txt b/Modules/Adapters/GdalAdapters/test/CMakeLists.txt index cf846f576dcde5eb4105e5a4366113d92494b7c2..11c44bb8c1a3684b88a9d97cc868dfd24a18bcd0 100644 --- a/Modules/Adapters/GdalAdapters/test/CMakeLists.txt +++ b/Modules/Adapters/GdalAdapters/test/CMakeLists.txt @@ -57,11 +57,28 @@ otb_add_test(NAME TvOGRExtendedFilename test.shp?&writegeom=ON&gdal:co:QUALITY=75&gdal:co:TILED=YES&gdal:co:BLOCKYSIZE=1024&gdal:lco:layeroption=OPTION&gdal:oo:openoption=OPTION ${TEMP}/TvOGRExtendedFilenameTest.txt ) -otb_add_test(NAME TvOGRExtendedFilenameGDAL +otb_add_test(NAME TvOGRExtendedFilenameGDALOpen COMMAND otbOGRTestDriver - otbOGRExtendedFileNameGDAL + otbOGRExtendedFileNameGDALOpen ${INPUTDATA}/ToulousePoints-examples.shp?&gdal:oo:openOption=OPTION - ${TEMP}/test.shp?&gdal:co:creationOption=OPTION&gdal:lco:layerOption=OPTION + ) + +otb_add_test(NAME TvOGRExtendedFilenameGDALCreate + COMMAND otbOGRTestDriver + otbOGRExtendedFileNameGDALCreate + test.shp?gdal:co:creationOption=OPTION + ) + +otb_add_test(NAME TvOGRExtendedFilenameGDALLayer + COMMAND otbOGRTestDriver + otbOGRExtendedFileNameGDALLayer + test.shp?&gdal:lco:layeroption=OPTION + ) + +otb_add_test(NAME TvOGRExtendedFilenameGDALLayerOption + COMMAND otbOGRTestDriver + otbOGRExtendedFileNameGDALLayerOption + test.shp ) diff --git a/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx index a35f21042f9b491c1c302f32770f770ba02a2750..cbfbe4f0e2763ac5a5182183705345cfaac05044 100644 --- a/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx +++ b/Modules/Adapters/GdalAdapters/test/otbOGRExtendedFilenameToOptionsGDALTest.cxx @@ -25,51 +25,44 @@ #include <fstream> -int otbOGRExtendedFileNameGDAL(int , char* argv[]) +int otbOGRExtendedFileNameGDALOpen(int , char* argv[]) { - bool success = true ; - const char * inputOpen = argv[1]; - const char * inputCreation = argv[2]; - auto test = otb::ogr::DataSource::New( inputOpen ); - // std::cout<<"here"<<std::endl; + auto test = otb::ogr::DataSource::New( argv[1] ); std::string error = CPLGetLastErrorMsg(); if ( !error.empty() ) std::cout<<error<<std::endl; - // if ( error.find( "does not support open option openOption" ) != std::string::npos ) - // success = true && success ; - // else - // success = false ; - // std::cout<<success<<std::endl; - + return 0; +} - test = otb::ogr::DataSource::New( inputCreation , otb::ogr::DataSource::Modes::Update_LayerOverwrite); -error = CPLGetLastErrorMsg(); - if ( !error.empty() ) - std::cout<<error<<std::endl; - // error = CPLGetLastErrorMsg(); - // std::cout<<error<<std::endl; - // if ( std::string(error).find( "does not support creation option creationOption" ) != std::string::npos ) - // success = true && success ; - // else - // success = false ; - // std::cout<<success<<std::endl; +int otbOGRExtendedFileNameGDALCreate(int , char* argv[]) +{ + auto test = otb::ogr::DataSource::New( argv[1] , otb::ogr::DataSource::Modes::Overwrite); + std::string error = CPLGetLastErrorMsg(); + std::cout<<error<<std::endl; + return error.empty(); +} +int otbOGRExtendedFileNameGDALLayer(int , char* argv[]) +{ + auto test = otb::ogr::DataSource::New( argv[1] , otb::ogr::DataSource::Modes::Update_LayerOverwrite); test->CreateLayer( "2layertest" , ITK_NULLPTR , - wkbUnknown , - std::vector< std::string > { "newOption=OPTION" } ); -error = CPLGetLastErrorMsg(); - if ( !error.empty() ) - std::cout<<error<<std::endl; - // error = CPLGetLastErrorMsg(); - // std::cout<<error<<std::endl; - // if ( std::string(error).find( "toto" ) != std::string::npos ) - // success = true && success; - // else - // success = false ; - // std::cout<<success<<std::endl; - - return EXIT_SUCCESS; + wkbUnknown ); + std::string error = CPLGetLastErrorMsg(); + std::cout<<error<<std::endl; + return error.empty(); } +int otbOGRExtendedFileNameGDALLayerOption(int , char* argv[]) +{ + auto test = otb::ogr::DataSource::New( argv[1] , otb::ogr::DataSource::Modes::Update_LayerOverwrite); + std::vector<std::string> option { "vectorlayeroption=OPTION" }; + test->CreateLayer( "2layertest" , + ITK_NULLPTR , + wkbUnknown , + option ); + std::string error = CPLGetLastErrorMsg(); + std::cout<<error<<std::endl; + return error.empty(); +} diff --git a/Modules/Adapters/GdalAdapters/test/otbOGRTestDriver.cxx b/Modules/Adapters/GdalAdapters/test/otbOGRTestDriver.cxx index 0793f8c07dfcf0b3b0e7a52b65c859df73d9fe35..dba04ea4d743cc89be61e25aa01978fd87882a5b 100644 --- a/Modules/Adapters/GdalAdapters/test/otbOGRTestDriver.cxx +++ b/Modules/Adapters/GdalAdapters/test/otbOGRTestDriver.cxx @@ -23,5 +23,8 @@ void RegisterTests() { REGISTER_TEST(otbOGRExtendedFileName); - REGISTER_TEST(otbOGRExtendedFileNameGDAL); + REGISTER_TEST(otbOGRExtendedFileNameGDALOpen); + REGISTER_TEST(otbOGRExtendedFileNameGDALCreate); + REGISTER_TEST(otbOGRExtendedFileNameGDALLayer); + REGISTER_TEST(otbOGRExtendedFileNameGDALLayerOption); }