21 #include "itkPSMContainer.h" 24 int itkPSMContainerTest(
int,
char* [] )
27 std::string errstring =
"";
29 const unsigned int SZ = 100;
35 typedef itk::Point<double, 3> PointType;
40 for (
unsigned int i = 0; i < SZ; i++)
42 pt[0] =
static_cast<double>(i) + 0.1f;
43 pt[1] =
static_cast<double>(i) + 0.2f;
44 pt[2] =
static_cast<double>(i) + 0.3f;
46 P->operator[](i) = pt;
53 errstring += std::string(
"GetSize method failed");
60 errstring += std::string(
"HasIndex method failed");
64 if (P->operator[](SZ-1)[0] != static_cast<double>(SZ-1) + 0.1f ||
65 P->operator[](SZ-1)[1] != static_cast<double>(SZ-1) + 0.2f ||
66 P->operator[](SZ-1)[2] != static_cast<double>(SZ-1) + 0.3f)
69 errstring += std::string(
"Accessor method failed or values were stored incorrectly.");
77 errstring += std::string(
"Erase method failed");
81 catch(itk::ExceptionObject &e)
83 errstring =
"ITK exception with description: " + std::string(e.GetDescription())
84 + std::string(
"\n at location:") + std::string(e.GetLocation())
85 + std::string(
"\n in file:") + std::string(e.GetFile());
90 errstring =
"Unknown exception thrown";
97 typedef itk::Point<double, 2> PointType;
102 for (
unsigned int i = 0; i < SZ; i++)
104 pt[0] =
static_cast<double>(i) + 0.1f;
105 pt[1] =
static_cast<double>(i) + 0.2f;
107 P->operator[](i) = pt;
114 errstring += std::string(
"GetSize method failed");
121 errstring += std::string(
"HasIndex method failed");
125 if (P->operator[](SZ-1)[0] != static_cast<double>(SZ-1) + 0.1f ||
126 P->operator[](SZ-1)[1] != static_cast<double>(SZ-1) + 0.2f)
129 errstring += std::string(
"Accessor method failed or values were stored incorrectly.");
137 errstring += std::string(
"Erase method failed");
141 catch(itk::ExceptionObject &e)
143 errstring =
"ITK exception with description: " + std::string(e.GetDescription())
144 + std::string(
"\n at location:") + std::string(e.GetLocation())
145 + std::string(
"\n in file:") + std::string(e.GetFile());
150 errstring =
"Unknown exception thrown";
158 std::cout <<
"All tests passed" << std::endl;
163 std::cout <<
"Test failed with the following error:" << std::endl;
164 std::cout << errstring << std::endl;
MapType::size_type Erase(const unsigned int &k)
bool HasIndex(unsigned long int k) const
unsigned long int GetSize() const
A container class that holds particle position information for the PSMParticleSystem class...