main_test.go 597 B

12345678910111213141516171819
  1. package main
  2. import "testing"
  3. func TestFitSize(t *testing.T) {
  4. cases := []struct{ areaW, areaH, w, h int }{
  5. {1920, 1032, 1280, 720}, // 1080p at 100%: capped at the largest size
  6. {1280, 688, 1100, 619}, // 1080p at 150% (taskbar removed): limited by height
  7. {1536, 824, 1280, 720}, // 1080p at 125%
  8. {2560, 1400, 1280, 720},
  9. {1024, 600, 960, 540}, // too small: the minimum
  10. {0, 0, 960, 540},
  11. }
  12. for _, c := range cases {
  13. if w, h := fitSize(c.areaW, c.areaH); w != c.w || h != c.h {
  14. t.Errorf("fitSize(%d, %d) = %d x %d, want %d x %d", c.areaW, c.areaH, w, h, c.w, c.h)
  15. }
  16. }
  17. }