From df0a026d9b5406246541a217172886ead1562aa4 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Mon, 11 Aug 2014 12:22:50 +0200 Subject: [PATCH] TEST: update tests for new command line parser --- .../Classification/CMakeLists.txt | 6 +-- .../Applications/Segmentation/CMakeLists.txt | 24 +++++----- .../Code/Wrappers/CommandLine/CMakeLists.txt | 10 ++--- .../otbWrapperCommandLineLauncherTests.cxx | 9 ++-- .../otbWrapperCommandLineParserTests.cxx | 44 ++++++++++++++----- 5 files changed, 56 insertions(+), 37 deletions(-) diff --git a/Testing/Applications/Classification/CMakeLists.txt b/Testing/Applications/Classification/CMakeLists.txt index 325e0076f5..558923a035 100644 --- a/Testing/Applications/Classification/CMakeLists.txt +++ b/Testing/Applications/Classification/CMakeLists.txt @@ -45,12 +45,12 @@ if(OTB_USE_OPENCV) set(knn_output_format ".knn") # Training algorithms parameters - set(libsvm_parameters "-classifier.libsvm.opt true") - set(svm_parameters "-classifier.svm.opt true") + set(libsvm_parameters "-classifier.libsvm.opt" "true") + set(svm_parameters "-classifier.svm.opt" "true") set(boost_parameters "") set(dt_parameters "") set(gbt_parameters "") - set(ann_parameters "-classifier.ann.sizes 100") + set(ann_parameters "-classifier.ann.sizes" "100") set(bayes_parameters "") set(rf_parameters "") set(knn_parameters "") diff --git a/Testing/Applications/Segmentation/CMakeLists.txt b/Testing/Applications/Segmentation/CMakeLists.txt index 3a1d1d096e..154b5bb078 100644 --- a/Testing/Applications/Segmentation/CMakeLists.txt +++ b/Testing/Applications/Segmentation/CMakeLists.txt @@ -60,17 +60,17 @@ OTB_TEST_APPLICATION(NAME apTvSeHooverCompareSegmentationTest #--- Segmentation ---# # Segmentation algorithms parameters -set(cc_parameters "-filter.cc.expr distance<25") -set(edison_parameters "-filter.edison.spatialr 5 -filter.edison.ranger 50 -filter.edison.minsize 10") -set(meanshift_parameters "-filter.meanshift.spatialr 5 -filter.meanshift.ranger 50 -filter.meanshift.minsize 10") -set(vector_parameters "-mode.vector.tilesize 500 -mode.vector.minsize 50 -mode.vector.simplify 0.1 -mode.vector.outmode ovw") +set(cc_parameters "-filter.cc.expr" "distance<25") +set(edison_parameters "-filter.edison.spatialr" "5" "-filter.edison.ranger" "50" "-filter.edison.minsize" "10") +set(meanshift_parameters "-filter.meanshift.spatialr" "5" "-filter.meanshift.ranger" "50" "-filter.meanshift.minsize" "10") +set(vector_parameters "-mode.vector.tilesize" "500" "-mode.vector.minsize" "50" "-mode.vector.simplify" "0.1" "-mode.vector.outmode" "ovw") # validation option set(meanshift_option "--without-threads") # Output type dependning on mode set(raster_output_format ".tif") -set(raster_output_option " uint16") +set(raster_output_option "uint16") set(vector_output_format ".sqlite") # Validation depending on mode @@ -98,7 +98,7 @@ OTB_TEST_APPLICATION(NAME apTvSeSegmentation${filter}${mode} -filter ${lfilter} ${${lfilter}_parameters} -mode ${lmode} - -mode.${lmode}.out ${TEMP}/${OUTFILE}${${lmode}_output_option} + -mode.${lmode}.out ${TEMP}/${OUTFILE} ${${lmode}_output_option} ${${lmode}_parameters} VALID ${${lfilter}_option} ${${lmode}_comparison} @@ -115,7 +115,7 @@ set(mode "Vector") string(TOLOWER ${filter} lfilter) # Add a test for ULOVW -set(vector_parameters "-mode.vector.tilesize 500 -mode.vector.minsize 50 -mode.vector.simplify 0.1 -mode.vector.outmode ulovw") +set(vector_parameters "-mode.vector.tilesize" "500" "-mode.vector.minsize" "50" "-mode.vector.simplify" "0.1" "-mode.vector.outmode" "ulovw") set(OUTFILE apTvSeSegmentation${filter}${mode}${${lmode}_output_format}) @@ -125,7 +125,7 @@ OTB_TEST_APPLICATION(NAME apTvSeSegmentation${filter}${mode}_ULOVW -filter ${lfilter} ${${lfilter}_parameters} -mode ${lmode} - -mode.${lmode}.out ${TEMP}/${OUTFILE}${${lmode}_output_option} + -mode.${lmode}.out ${TEMP}/${OUTFILE} ${${lmode}_output_option} ${${lmode}_parameters} VALID ${${lfilter}_option} ${${lmode}_comparison} @@ -138,7 +138,7 @@ set_tests_properties(apTvSeSegmentation${filter}${mode}_ULOVW RESOURCE_LOCK ${OUTFILE}) # Add a test for ULU -set(vector_parameters "-mode.vector.tilesize 500 -mode.vector.minsize 50 -mode.vector.simplify 0.1 -mode.vector.outmode ulu") +set(vector_parameters "-mode.vector.tilesize" "500" "-mode.vector.minsize" "50" "-mode.vector.simplify" "0.1" "-mode.vector.outmode" "ulu") OTB_TEST_APPLICATION(NAME apTvSeSegmentation${filter}${mode}_ULU APP Segmentation @@ -146,7 +146,7 @@ OTB_TEST_APPLICATION(NAME apTvSeSegmentation${filter}${mode}_ULU -filter ${lfilter} ${${lfilter}_parameters} -mode ${lmode} - -mode.${lmode}.out ${TEMP}/${OUTFILE}${${lmode}_output_option} + -mode.${lmode}.out ${TEMP}/${OUTFILE} ${${lmode}_output_option} ${${lmode}_parameters} VALID ${${lfilter}_option} ${${lmode}_comparison} @@ -159,7 +159,7 @@ set_tests_properties(apTvSeSegmentation${filter}${mode}_ULU RESOURCE_LOCK ${OUTFILE}) # Add a test for ULCO -set(vector_parameters "-mode.vector.tilesize 500 -mode.vector.minsize 50 -mode.vector.simplify 0.1 -mode.vector.outmode ulco") +set(vector_parameters "-mode.vector.tilesize" "500" "-mode.vector.minsize" "50" "-mode.vector.simplify" "0.1" "-mode.vector.outmode" "ulco") OTB_TEST_APPLICATION(NAME apTvSeSegmentation${filter}${mode}_ULCO APP Segmentation @@ -167,7 +167,7 @@ OTB_TEST_APPLICATION(NAME apTvSeSegmentation${filter}${mode}_ULCO -filter ${lfilter} ${${lfilter}_parameters} -mode ${lmode} - -mode.${lmode}.out ${TEMP}/${OUTFILE}${${lmode}_output_option} + -mode.${lmode}.out ${TEMP}/${OUTFILE} ${${lmode}_output_option} ${${lmode}_parameters} VALID ${${lfilter}_option} ${${lmode}_comparison} diff --git a/Testing/Code/Wrappers/CommandLine/CMakeLists.txt b/Testing/Code/Wrappers/CommandLine/CMakeLists.txt index 94f236ad0b..71f4c5bd9f 100644 --- a/Testing/Code/Wrappers/CommandLine/CMakeLists.txt +++ b/Testing/Code/Wrappers/CommandLine/CMakeLists.txt @@ -14,28 +14,28 @@ add_test(NAME clTuWrapperCommandLineParserNew add_test(NAME clTvWrapperCommandLineParserTest_GetAtt COMMAND ${OTB_WRAPPER_COMMAND_LINE_TESTS} otbWrapperCommandLineParserTest1 "-key" - "this is a line test to extract -key name1 name2" ) + "this" "is" "a" "line" "test" "to" "extract" "-key" "name1" "name2" ) add_test(NAME clTvWrapperCommandLineParserTest_IsAttExists_Wrong COMMAND ${OTB_WRAPPER_COMMAND_LINE_TESTS} otbWrapperCommandLineParserTest3 "-m" - " TrainImagesClassifier test -il QB_1_ortho.tif -vd vd .shape " ) + "TrainImagesClassifier" "test" "-il" "QB_1_ortho.tif" "-vd" "vd" ".shape" ) add_test(NAME clTvWrapperCommandLineParserTest_IsAttExists COMMAND ${OTB_WRAPPER_COMMAND_LINE_TESTS} otbWrapperCommandLineParserTest4 "-m" - " TrainImagesClassifier test -il QB_1_ortho.tif -vd vd .shape -m name") + "TrainImagesClassifier" "test" "-il" "QB_1_ortho.tif" "-vd" "vd" ".shape" "-m" "name") add_test(NAME clTvWrapperCommandLineParserTest_IsAttExistsEnd COMMAND ${OTB_WRAPPER_COMMAND_LINE_TESTS} otbWrapperCommandLineParserTest4 "-m" - " TrainImagesClassifier test -il QB_1_ortho.tif -vd vd .shape -m name") + "TrainImagesClassifier" "test" "-il" "QB_1_ortho.tif" "-vd" "vd" ".shape" "-m" "name") add_test(NAME clTvWrapperCommandLineParserTest_IsAttExistsEndNoParam COMMAND ${OTB_WRAPPER_COMMAND_LINE_TESTS} otbWrapperCommandLineParserTest4 "-m" - " TrainImagesClassifier test -il QB_1_ortho.tif -vd vd .shape test -m") + "TrainImagesClassifier" "test" "-il" "QB_1_ortho.tif" "-vd" "vd" ".shape" "test" "-m") add_test(NAME clTvWrapperCommandLineParserTest_GetAttWithoutValue COMMAND ${OTB_WRAPPER_COMMAND_LINE_TESTS} otbWrapperCommandLineParserTest1 diff --git a/Testing/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncherTests.cxx b/Testing/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncherTests.cxx index 7b75586869..63967a967a 100644 --- a/Testing/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncherTests.cxx +++ b/Testing/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncherTests.cxx @@ -38,17 +38,16 @@ int otbWrapperCommandLineLauncherTest(int argc, char* argv[]) typedef otb::Wrapper::CommandLineLauncher LauncherType; LauncherType::Pointer launcher = LauncherType::New(); - std::ostringstream input; + std::vector<std::string> cmdVector; if (argc > 2) { - input << argv[1]; - for (int i = 2; i < argc; i++) + for (int i = 1; i < argc; i++) { - input << " " << argv[i]; + cmdVector.push_back(std::string(argv[i])); } } - if (launcher->Load(input.str()) == true) + if (launcher->Load(cmdVector) == true) { if (launcher->ExecuteAndWriteOutput() == false) { diff --git a/Testing/Code/Wrappers/CommandLine/otbWrapperCommandLineParserTests.cxx b/Testing/Code/Wrappers/CommandLine/otbWrapperCommandLineParserTests.cxx index 852a6b8376..d0d33c4571 100644 --- a/Testing/Code/Wrappers/CommandLine/otbWrapperCommandLineParserTests.cxx +++ b/Testing/Code/Wrappers/CommandLine/otbWrapperCommandLineParserTests.cxx @@ -69,11 +69,16 @@ int CheckReturn(ParserType::ParseResultType res) } -int otbWrapperCommandLineParserTest1(int itkNotUsed(argc), char* argv[]) +int otbWrapperCommandLineParserTest1(int argc, char* argv[]) { ParserType::Pointer parser = ParserType::New(); + std::vector<std::string> cmdVector; + for (int i=2 ; i<argc ; ++i) + { + cmdVector.push_back(std::string(argv[i])); + } - std::vector<std::string> res = parser->GetAttribut( argv[1], argv[2] ); + std::vector<std::string> res = parser->GetAttribut( argv[1], cmdVector ); if( res.size() == 0 ) { @@ -89,18 +94,17 @@ int otbWrapperCommandLineParserTest2(int argc, char* argv[]) std::cout << "Search for paths..." << std::endl; - std::ostringstream input; + std::vector<std::string> cmdVector; if (argc > 2) { - input << argv[1]; - for (int i = 2; i < argc; i++) + for (int i=1 ; i<argc ; ++i) { - input << " " << argv[i]; + cmdVector.push_back(std::string(argv[i])); } } std::vector<std::string> paths; - ParserType::ParseResultType res = parser->GetPaths(paths, input.str()); + ParserType::ParseResultType res = parser->GetPaths(paths, cmdVector); if (CheckReturn(res) != ParserType::OK) { std::cout << "Can't find paths." << std::endl; @@ -111,7 +115,7 @@ int otbWrapperCommandLineParserTest2(int argc, char* argv[]) std::cout << "Search for module name..." << std::endl; std::string name; - res = parser->GetModuleName(name, argv[1]); + res = parser->GetModuleName(name, cmdVector); if (CheckReturn(res) != ParserType::OK) { @@ -123,11 +127,19 @@ int otbWrapperCommandLineParserTest2(int argc, char* argv[]) return CheckReturn(res); } -int otbWrapperCommandLineParserTest3(int itkNotUsed(argc), char* argv[]) +int otbWrapperCommandLineParserTest3(int argc, char* argv[]) { ParserType::Pointer parser = ParserType::New(); + std::vector<std::string> cmdVector; + if (argc > 2) + { + for (int i=2 ; i<argc ; ++i) + { + cmdVector.push_back(std::string(argv[i])); + } + } - if (parser->IsAttributExists(argv[1], argv[2])) + if (parser->IsAttributExists(argv[1], cmdVector)) { return EXIT_FAILURE; } @@ -135,11 +147,19 @@ int otbWrapperCommandLineParserTest3(int itkNotUsed(argc), char* argv[]) } -int otbWrapperCommandLineParserTest4(int itkNotUsed(argc), char* argv[]) +int otbWrapperCommandLineParserTest4(int argc, char* argv[]) { ParserType::Pointer parser = ParserType::New(); + std::vector<std::string> cmdVector; + if (argc > 2) + { + for (int i=2 ; i<argc ; ++i) + { + cmdVector.push_back(std::string(argv[i])); + } + } - if (parser->IsAttributExists(argv[1], argv[2])) + if (parser->IsAttributExists(argv[1], cmdVector)) { return EXIT_SUCCESS; } -- GitLab