feat(lab5): time pipeline stages and centralize variant constants

This commit is contained in:
Mikhail Verkovykh
2026-11-20 19:05:27 +03:00
parent 1ce93185af
commit d0f533b371
5 changed files with 121 additions and 36 deletions
+20 -3
View File
@@ -34,9 +34,26 @@ func TestFitSizePreservesAspectAndNeverUpscales(t *testing.T) {
}
}
func TestProcessReportsTiming(t *testing.T) {
file := pngFile(t, 320, 200, false)
_, stats, err := New(40_000_000, 256<<20).Process(context.Background(), file)
if err != nil {
t.Fatalf("Process: %v", err)
}
if stats.Decode <= 0 || stats.Scale <= 0 || stats.JPEGEncode <= 0 || stats.WebPEncode <= 0 {
t.Fatalf("incomplete timing stats: %+v", stats)
}
if stats.Total() != stats.Decode+stats.Scale+stats.JPEGEncode+stats.WebPEncode {
t.Fatalf("total %v does not match its parts: %+v", stats.Total(), stats)
}
if stats.Total() <= 0 {
t.Fatalf("total timing must be positive: %+v", stats)
}
}
func TestProcessProducesContractVariants(t *testing.T) {
file := pngFile(t, 320, 200, false)
variants, err := New(40_000_000, 256<<20).Process(context.Background(), file)
variants, _, err := New(40_000_000, 256<<20).Process(context.Background(), file)
if err != nil {
t.Fatalf("Process: %v", err)
}
@@ -73,7 +90,7 @@ func TestProcessProducesContractVariants(t *testing.T) {
func TestThumbnailCompositesAlphaOnWhite(t *testing.T) {
file := pngFile(t, 64, 64, true)
variants, err := New(40_000_000, 256<<20).Process(context.Background(), file)
variants, _, err := New(40_000_000, 256<<20).Process(context.Background(), file)
if err != nil {
t.Fatalf("Process: %v", err)
}
@@ -92,7 +109,7 @@ func TestEXIFOrientationRotatesBeforeResize(t *testing.T) {
if got := jpegOrientation(file); got != 6 {
t.Fatalf("jpegOrientation = %d, want 6", got)
}
variants, err := New(40_000_000, 256<<20).Process(context.Background(), file)
variants, _, err := New(40_000_000, 256<<20).Process(context.Background(), file)
if err != nil {
t.Fatalf("Process: %v", err)
}