MCPcopy Index your code
hub / github.com/willnorris/imageproxy / TestTrimEdges

Function TestTrimEdges

transform_test.go:393–465  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

391}
392
393func TestTrimEdges(t *testing.T) {
394 x := color.NRGBA{255, 255, 255, 255}
395 o := color.NRGBA{0, 0, 0, 255}
396
397 tests := []struct {
398 name string
399 src image.Image // source image to transform
400 want image.Image // expected transformed image
401 }{
402 {
403 name: "empty",
404 src: newImage(0, 0),
405 want: newImage(0, 0), // same as src
406 },
407 {
408 name: "solid",
409 src: newImage(8, 8, x),
410 want: newImage(8, 8, x), // same as src
411 },
412 {
413 name: "square",
414 src: newImage(4, 4,
415 x, x, x, x,
416 x, o, o, x,
417 x, o, o, x,
418 x, x, x, x,
419 ),
420 want: newImage(2, 2,
421 o, o,
422 o, o,
423 ),
424 },
425 {
426 name: "diamond",
427 src: newImage(5, 5,
428 x, x, x, x, x,
429 x, x, o, x, x,
430 x, o, o, o, x,
431 x, x, o, x, x,
432 x, x, x, x, x,
433 ),
434 want: newImage(3, 3,
435 x, o, x,
436 o, o, o,
437 x, o, x,
438 ),
439 },
440 {
441 name: "irregular",
442 src: newImage(5, 5,
443 x, o, x, x, x,
444 x, o, o, x, x,
445 x, o, o, x, x,
446 x, x, x, x, x,
447 x, x, x, x, x,
448 ),
449 want: newImage(2, 3,
450 o, x,

Callers

nothing calls this directly

Calls 2

newImageFunction · 0.85
trimEdgesFunction · 0.85

Tested by

no test coverage detected