| 195 | } |
| 196 | |
| 197 | func (s *ImageHashTestSuite) TestSHA256HashDifference() { |
| 198 | // Load original image hash |
| 199 | originalHash := s.calcHash("dct2/original.png", testutil.HashTypeSHA256) |
| 200 | |
| 201 | testCases := []string{ |
| 202 | "dct2/brightness-minus1.png", |
| 203 | "dct2/jpeg-q80.jpg", |
| 204 | "dct2/hue-plus1.png", |
| 205 | "dct2/region-5x5-hue-plus1.png", |
| 206 | } |
| 207 | |
| 208 | for _, filename := range testCases { |
| 209 | s.Run(filename, func() { |
| 210 | testHash := s.calcHash(filename, testutil.HashTypeSHA256) |
| 211 | |
| 212 | distance, err := originalHash.Distance(testHash) |
| 213 | s.Require().NoError(err) |
| 214 | |
| 215 | // Check that the hash of the modified image is different from the original hash |
| 216 | s.Require().NotEqual(0, distance, "hash should differ for modified image") |
| 217 | }) |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | func (s *ImageHashTestSuite) calcHash( |
| 222 | filename string, hashType testutil.ImageHashType, |