Commit db7f22c9 authored by Julien Michel's avatar Julien Michel

TEST: Fixing failing tests caused by coverity issues fixes

parent e3d488e1
......@@ -99,13 +99,7 @@ int otbSVMModelGenericKernelsTest(int argc, char* argv[])
for (int i = 0; i < model->nr_class - 1; ++i)
model->sv_coef[i] = new double[model->l];
model->SV = new svm_node *[model->l];
for (int n = 0; n < model->l; ++n)
{
model->SV[n] = new svm_node[1];
model->SV[n]->index = -1;
model->SV[n]->value = 0.;
}
model->sv_coef[0][0] = 0.125641;
model->sv_coef[0][1] = 1;
model->sv_coef[0][2] = 0;
......@@ -238,12 +232,8 @@ int otbSVMModelGenericKernelsTest(int argc, char* argv[])
}
delete [] model->sv_coef;
for (int n = 0; n < model->l; ++n)
{
delete [] model->SV[n];
}
delete [] model->SV;
delete model->rho;
delete model->probA;
delete model->probB;
......
......@@ -35,14 +35,14 @@ int otbSVMComposedKernelFunctorTest( int itkNotUsed(argc), char* argv[] )
ModelType::Pointer svmModel = ModelType::New();
otb::CustomKernelFunctor customFunctor;
otb::SAMKernelFunctor SAMFunctor;
ComposedKernelFunctor composedKernelFunctor;
composedKernelFunctor.AddKernelFunctorModelToKernelList(&customFunctor);
composedKernelFunctor.AddKernelFunctorModelToKernelList(&SAMFunctor);
composedKernelFunctor.AddPonderationToPonderationList(1.5);
composedKernelFunctor.AddPonderationToPonderationList(2.0);
composedKernelFunctor.SetName("compositionFilter");
otb::CustomKernelFunctor * customFunctor = new otb::CustomKernelFunctor;
otb::SAMKernelFunctor * SAMFunctor = new otb::SAMKernelFunctor;
ComposedKernelFunctor * composedKernelFunctor = new ComposedKernelFunctor;
composedKernelFunctor->AddKernelFunctorModelToKernelList(customFunctor);
composedKernelFunctor->AddKernelFunctorModelToKernelList(SAMFunctor);
composedKernelFunctor->AddPonderationToPonderationList(1.5);
composedKernelFunctor->AddPonderationToPonderationList(2.0);
composedKernelFunctor->SetName("compositionFilter");
struct svm_model *model;
model = new svm_model;
......@@ -87,7 +87,7 @@ int otbSVMComposedKernelFunctorTest( int itkNotUsed(argc), char* argv[] )
model->nSV[0] = 3;
model->nSV[1] = 2;
model->param.kernel_composed = &composedKernelFunctor;
model->param.kernel_composed = composedKernelFunctor;
svmModel->SetModel(model);
struct svm_node *x = new svm_node[3];
......@@ -95,8 +95,6 @@ int otbSVMComposedKernelFunctorTest( int itkNotUsed(argc), char* argv[] )
struct svm_node **SVx = new svm_node*[1];
struct svm_node **SVy = new svm_node*[1];
SVx[0] = new svm_node[1];
SVy[0] = new svm_node[1];
SVx[0] = &x[0];
SVy[0] = &y[0];
......@@ -125,10 +123,10 @@ int otbSVMComposedKernelFunctorTest( int itkNotUsed(argc), char* argv[] )
file<<"Functor Results:"<<std::endl;
res1 = customFunctor(SVx[0], SVy[0], model->param);
res1 = (*customFunctor)(SVx[0], SVy[0], model->param);
file<<"Custom Functor only: "<<res1<<std::endl;
//std::cout<<"customFunctor : "<<res1<<std::endl;
res2 = SAMFunctor(SVx[0], SVy[0], model->param);
res2 = (*SAMFunctor)(SVx[0], SVy[0], model->param);
file<<"SAM Functor only: "<<res2<<std::endl;
//std::cout<<"SAMFunctor : "<<res2<<std::endl;
file<<"Composed Functor: "<<std::endl;
......@@ -172,12 +170,12 @@ int otbSVMComposedKernelFunctorTest( int itkNotUsed(argc), char* argv[] )
delete [] model->nSV;
delete [] x;
delete [] y;
delete [] SVx[0];
delete [] SVy[0];
delete [] SVx;
delete [] SVy;
delete model;
svmModel = NULL;
return EXIT_SUCCESS;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment