Skip to content

Commit

Permalink
Refs #11762. replace owning raw pointer with std::vector<T>.
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumsteve committed May 14, 2015
1 parent 938e64e commit 233a65d
Showing 1 changed file with 6 additions and 12 deletions.
Expand Up @@ -161,12 +161,12 @@ class vtkDataSetToNonOrthogonalDataSetTest : public CxxTest::TestSuite
}

template<typename T>
T *getRangeComp(vtkDataSet *ds, std::string fieldname, int size)
std::vector<T> getRangeComp(vtkDataSet *ds, std::string fieldname, int size)
{
vtkDataArray *arr = ds->GetFieldData()->GetArray(fieldname.c_str());
vtkTypedDataArray<T>* tarr = vtkTypedDataArray<T>::FastDownCast(arr);
T *vals = new T[size];
tarr->GetTupleValue(0, vals);
std::vector<T> vals(size);
tarr->GetTupleValue(0, &vals[0]);
return vals;
}

Expand All @@ -183,7 +183,7 @@ class vtkDataSetToNonOrthogonalDataSetTest : public CxxTest::TestSuite
TS_ASSERT_DELTA(point[2], 0.8660254, eps);
// See if the basis vectors are available

double *basisMatrix = getRangeComp<double>(grid, "ChangeOfBasisMatrix", 16);
std::vector<double> basisMatrix = getRangeComp<double>(grid, "ChangeOfBasisMatrix", 16);

// Row by row check

Expand Down Expand Up @@ -211,8 +211,6 @@ class vtkDataSetToNonOrthogonalDataSetTest : public CxxTest::TestSuite
TS_ASSERT_DELTA(basisMatrix[index++], 0.0, eps);
TS_ASSERT_DELTA(basisMatrix[index++], 0.0, eps);
TS_ASSERT_DELTA(basisMatrix[index++], 1.0, eps);

delete basisMatrix;
}

public:
Expand Down Expand Up @@ -313,7 +311,7 @@ class vtkDataSetToNonOrthogonalDataSetTest : public CxxTest::TestSuite
TS_ASSERT_DELTA(point[1], 1.0, eps);
TS_ASSERT_DELTA(point[2], 1.0, eps);
// See if the basis vectors are available
double *basisMatrix = getRangeComp<double>(ds, "ChangeOfBasisMatrix", 16);
std::vector<double> basisMatrix = getRangeComp<double>(ds, "ChangeOfBasisMatrix", 16);

// Row by row check

Expand Down Expand Up @@ -342,8 +340,6 @@ class vtkDataSetToNonOrthogonalDataSetTest : public CxxTest::TestSuite
TS_ASSERT_DELTA(basisMatrix[index++], 0.0, eps);
TS_ASSERT_DELTA(basisMatrix[index++], 1.0, eps);

delete basisMatrix;

ds->Delete();
}

Expand Down Expand Up @@ -371,7 +367,7 @@ class vtkDataSetToNonOrthogonalDataSetTest : public CxxTest::TestSuite
TS_ASSERT_DELTA(point[1], 1.0, eps);
TS_ASSERT_DELTA(point[2], 0.75592895, eps);
// See if the basis vectors are available
double *basisMatrix = getRangeComp<double>(ds, "ChangeOfBasisMatrix", 16);
std::vector<double> basisMatrix = getRangeComp<double>(ds, "ChangeOfBasisMatrix", 16);

// Row by row check

Expand Down Expand Up @@ -400,8 +396,6 @@ class vtkDataSetToNonOrthogonalDataSetTest : public CxxTest::TestSuite
TS_ASSERT_DELTA(basisMatrix[index++], 0.0, eps);
TS_ASSERT_DELTA(basisMatrix[index++], 1.0, eps);

delete basisMatrix;

ds->Delete();
}
};
Expand Down

0 comments on commit 233a65d

Please sign in to comment.