diff --git a/testing/apps/DoseAcc/DoseAccInvalidParametersTest.cpp b/testing/apps/DoseAcc/DoseAccInvalidParametersTest.cpp index d67f07f..6e77be6 100644 --- a/testing/apps/DoseAcc/DoseAccInvalidParametersTest.cpp +++ b/testing/apps/DoseAcc/DoseAccInvalidParametersTest.cpp @@ -1,97 +1,98 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ #include #include "litCheckMacros.h" #include "boost/filesystem.hpp" namespace rttb { namespace testing { //path to the current running directory. DoseTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int DoseAccInvalidParametersTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string doseAccExecutable; if (argc > 1) { doseAccExecutable = argv[1]; } boost::filesystem::path callingPath(_callingAppPath); - std::string doseAccExeWithPath = callingPath.parent_path().string() + "/" + doseAccExecutable; + auto doseAccExecutablePath = callingPath.parent_path() / doseAccExecutable; + std::string doseAccExeWithPath = doseAccExecutablePath.string(); //call with too few parameters std::string toofewParametersCommand = doseAccExeWithPath; toofewParametersCommand += " test"; std::cout << "Command line call: " + toofewParametersCommand << std::endl; CHECK_EQUAL(system(toofewParametersCommand.c_str()) != 0, true); toofewParametersCommand = doseAccExeWithPath; toofewParametersCommand += " test test"; std::cout << "Command line call: " + toofewParametersCommand << std::endl; CHECK_EQUAL(system(toofewParametersCommand.c_str()) != 0, true); toofewParametersCommand = doseAccExeWithPath; toofewParametersCommand += " -d test"; toofewParametersCommand += " -e test"; std::cout << "Command line call: " + toofewParametersCommand << std::endl; CHECK_EQUAL(system(toofewParametersCommand.c_str()) != 0, true); std::string minimalCLI = doseAccExeWithPath + " test test test "; //call with invalid interpolator std::string invalidInterpolatorOption = minimalCLI; invalidInterpolatorOption += "-i wrongInterpolator"; std::cout << "Command line call: " + invalidInterpolatorOption << std::endl; CHECK_EQUAL(system(invalidInterpolatorOption.c_str()) != 0, true); //call with invalid operator std::string invalidOperatorOption = minimalCLI; invalidOperatorOption += "-p -"; std::cout << "Command line call: " + invalidOperatorOption << std::endl; CHECK_EQUAL(system(invalidOperatorOption.c_str()) != 0, true); //call with operator* and weight std::string invalidOperatorMultWithWeightOption = minimalCLI; invalidOperatorMultWithWeightOption += "-p * --weight1 2.0"; std::cout << "Command line call: " + invalidOperatorMultWithWeightOption << std::endl; CHECK_EQUAL(system(invalidOperatorMultWithWeightOption.c_str()) != 0, true); //call with invalid dose1 load option std::string invalidDose1LoadOption = minimalCLI; invalidDose1LoadOption += "-t invalidLoadStyleOption"; std::cout << "Command line call: " + invalidDose1LoadOption << std::endl; CHECK_EQUAL(system(invalidDose1LoadOption.c_str()) != 0, true); //call with invalid dose2 load option std::string invalidDose2LoadOption = minimalCLI; invalidDose2LoadOption += "-u invalidLoadStyleOption"; std::cout << "Command line call: " + invalidDose2LoadOption << std::endl; CHECK_EQUAL(system(invalidDose2LoadOption.c_str()) != 0, true); RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace rttb diff --git a/testing/apps/DoseAcc/DoseAccNeutralWeightTest.cpp b/testing/apps/DoseAcc/DoseAccNeutralWeightTest.cpp index b08592d..a816855 100644 --- a/testing/apps/DoseAcc/DoseAccNeutralWeightTest.cpp +++ b/testing/apps/DoseAcc/DoseAccNeutralWeightTest.cpp @@ -1,102 +1,103 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ #include "litCheckMacros.h" #include "litImageTester.h" #include "boost/filesystem.hpp" #include "itkImage.h" #include "rttbITKIOHelper.h" namespace rttb { namespace testing { //path to the current running directory. DoseTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int DoseAccNeutralWeightTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string doseAccExecutable; std::string doseFilename; std::string referenceFilename; std::string reference2Filename; boost::filesystem::path callingPath(_callingAppPath); if (argc > 4) { doseAccExecutable = argv[1]; doseFilename = argv[2]; referenceFilename = argv[3]; reference2Filename = argv[4]; } - std::string doseAccExeWithPath = callingPath.parent_path().string() + "/" + doseAccExecutable; + auto doseAccExecutablePath = callingPath.parent_path() / doseAccExecutable; + std::string doseAccExeWithPath = doseAccExecutablePath.string(); const std::string defaultOutputAddFilename = "doseAccAddOutput.nrrd"; const std::string defaultOutputMultFilename = "doseAccMultOutput.nrrd"; std::string baseCommand = doseAccExeWithPath; baseCommand += " -d \"" + doseFilename + "\""; baseCommand += " -e \"" + doseFilename + "\""; std::string defaultDoseAccAddCommand = baseCommand + " -o " + defaultOutputAddFilename + " --weight1 0.0"; std::cout << "Command line call: " + defaultDoseAccAddCommand << std::endl; CHECK_EQUAL(system(defaultDoseAccAddCommand.c_str()), 0); CHECK_EQUAL(boost::filesystem::exists(defaultOutputAddFilename), true); std::string defaultDoseAccMultCommand = baseCommand + " -o " + defaultOutputMultFilename + " --operator \"*\""; std::cout << "Command line call: " + defaultDoseAccMultCommand << std::endl; CHECK_EQUAL(system(defaultDoseAccMultCommand.c_str()), 0); CHECK_EQUAL(boost::filesystem::exists(defaultOutputMultFilename), true); // Check result against reference typedef ::itk::Image TestImageType; TestImageType::Pointer referenceAddImage = io::itk::readITKDoubleImage(referenceFilename); TestImageType::Pointer outputAddImage = io::itk::readITKDoubleImage(defaultOutputAddFilename); lit::ImageTester tester; tester.setExpectedImage(referenceAddImage); tester.setActualImage(outputAddImage); tester.setCheckThreshold(1e-5); CHECK_TESTER(tester); TestImageType::Pointer referenceMultImage = io::itk::readITKDoubleImage(reference2Filename); TestImageType::Pointer outputMultImage = io::itk::readITKDoubleImage(defaultOutputMultFilename); tester.setExpectedImage(referenceMultImage); tester.setActualImage(outputMultImage); tester.setCheckThreshold(1e-5); CHECK_TESTER(tester); CHECK_EQUAL(std::remove(defaultOutputAddFilename.c_str()), 0); CHECK_EQUAL(std::remove(defaultOutputMultFilename.c_str()), 0); RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace rttb diff --git a/testing/apps/DoseAcc/DoseAccSimpleTest.cpp b/testing/apps/DoseAcc/DoseAccSimpleTest.cpp index 6fb8af3..0d42af1 100644 --- a/testing/apps/DoseAcc/DoseAccSimpleTest.cpp +++ b/testing/apps/DoseAcc/DoseAccSimpleTest.cpp @@ -1,86 +1,87 @@ // ----------------------------------------------------------------------- // RTToolbox - DKFZ radiotherapy quantitative evaluation library // // Copyright (c) German Cancer Research Center (DKFZ), // Software development for Integrated Diagnostics and Therapy (SIDT). // ALL RIGHTS RESERVED. // See rttbCopyright.txt or // http://www.dkfz.de/en/sidt/projects/rttb/copyright.html // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notices for more information. // //------------------------------------------------------------------------ #include "litCheckMacros.h" #include "litImageTester.h" #include "boost/filesystem.hpp" #include "itkImage.h" #include "rttbITKIOHelper.h" namespace rttb { namespace testing { //path to the current running directory. DoseTool is in the same directory (Debug/Release) extern const char* _callingAppPath; int DoseAccSimpleTest(int argc, char* argv[]) { PREPARE_DEFAULT_TEST_REPORTING; std::string doseAccExecutable; std::string dose1Filename; std::string dose2Filename; std::string referenceFilename; boost::filesystem::path callingPath(_callingAppPath); if (argc > 4) { doseAccExecutable = argv[1]; dose1Filename = argv[2]; dose2Filename = argv[3]; referenceFilename = argv[4]; } - std::string doseAccExeWithPath = callingPath.parent_path().string() + "/" + doseAccExecutable; + auto doseAccExecutablePath = callingPath.parent_path() / doseAccExecutable; + std::string doseAccExeWithPath = doseAccExecutablePath.string(); std::string defaultOutputFilename = "doseAccOutput.nrrd"; std::string baseCommand = doseAccExeWithPath; baseCommand += " -d \"" + dose1Filename + "\""; baseCommand += " -e \"" + dose2Filename + "\""; baseCommand += " -o " + defaultOutputFilename; std::string defaultDoseAccCommand = baseCommand + " --weight1 2.0"; std::cout << "Command line call: " + defaultDoseAccCommand << std::endl; CHECK_EQUAL(system(defaultDoseAccCommand.c_str()), 0); CHECK_EQUAL(boost::filesystem::exists(defaultOutputFilename), true); // Check result against reference typedef ::itk::Image TestImageType; TestImageType::Pointer referenceImage = io::itk::readITKDoubleImage(referenceFilename); TestImageType::Pointer outputImage = io::itk::readITKDoubleImage(defaultOutputFilename); lit::ImageTester tester; tester.setExpectedImage(referenceImage); tester.setActualImage(outputImage); tester.setCheckThreshold(0.0); CHECK_TESTER(tester); CHECK_EQUAL(std::remove(defaultOutputFilename.c_str()), 0); RETURN_AND_REPORT_TEST_SUCCESS; } } //namespace testing } //namespace rttb