MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / TestSHA256HashDifference

Method TestSHA256HashDifference

testutil/image_hash_test.go:197–219  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

195}
196
197func (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
221func (s *ImageHashTestSuite) calcHash(
222 filename string, hashType testutil.ImageHashType,

Callers

nothing calls this directly

Calls 3

calcHashMethod · 0.95
RunMethod · 0.80
DistanceMethod · 0.80

Tested by

no test coverage detected