| 23 | #include <sitkCastImageFilter.h> |
| 24 | |
| 25 | class HashImageFilterTest : public ::testing::Test |
| 26 | { |
| 27 | public: |
| 28 | template <typename TPixelType, unsigned int IDimension> |
| 29 | void |
| 30 | CheckImageHashMD5(const std::string & fname, const std::string & expectedHash) |
| 31 | { |
| 32 | |
| 33 | using ReaderType = itk::ImageFileReader<itk::Image<TPixelType, IDimension>>; |
| 34 | typename ReaderType::Pointer reader = ReaderType::New(); |
| 35 | reader->SetFileName(dataFinder.GetFile(fname)); |
| 36 | reader->Update(); |
| 37 | |
| 38 | using HasherType = itk::HashImageFilter<itk::Image<TPixelType, IDimension>>; |
| 39 | typename HasherType::Pointer hasher = HasherType::New(); |
| 40 | hasher->SetHashFunction(HasherType::MD5); |
| 41 | hasher->SetInput(reader->GetOutput()); |
| 42 | hasher->Update(); |
| 43 | |
| 44 | EXPECT_EQ(expectedHash, hasher->GetHash()); |
| 45 | } |
| 46 | |
| 47 | template <typename TPixelType, unsigned int IDimension> |
| 48 | void |
| 49 | CheckImageHashSHA1(const std::string & fname, const std::string & expectedHash) |
| 50 | { |
| 51 | |
| 52 | using ReaderType = itk::ImageFileReader<itk::Image<TPixelType, IDimension>>; |
| 53 | typename ReaderType::Pointer reader = ReaderType::New(); |
| 54 | reader->SetFileName(dataFinder.GetFile(fname)); |
| 55 | reader->Update(); |
| 56 | |
| 57 | using HasherType = itk::HashImageFilter<itk::Image<TPixelType, IDimension>>; |
| 58 | typename HasherType::Pointer hasher = HasherType::New(); |
| 59 | hasher->SetHashFunction(HasherType::SHA1); |
| 60 | hasher->SetInput(reader->GetOutput()); |
| 61 | hasher->Update(); |
| 62 | |
| 63 | EXPECT_EQ(expectedHash, hasher->GetHash()); |
| 64 | } |
| 65 | }; |
| 66 | |
| 67 | TEST_F(HashImageFilterTest, InstantiateTest) |
| 68 | { |
nothing calls this directly
no outgoing calls
no test coverage detected