Skip to content

Commit

Permalink
Update constraint and test case
Browse files Browse the repository at this point in the history
  • Loading branch information
fanyu committed Oct 20, 2021
1 parent a388f78 commit a3dd3e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ enum PhotoSizeCalculator {
if contentRatio > 1 {
if contentRatio > Height.max / Width.max {
height = Height.max
width = round(height / contentRatio)
width = max(Width.min, round(height / contentRatio))
} else {
width = Width.max
height = round(width * contentRatio)
height = min(Height.max, round(width * contentRatio))
}
} else {
width = Width.max
Expand Down
8 changes: 4 additions & 4 deletions MixinTests/PhotoDisplayTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ class PhotoDisplayTests: XCTestCase {
let expected = [
// Bad input
CGSize(width: 120, height: 120),

// General photos
CGSize(width: 210, height: 280),
CGSize(width: 210, height: 158),

// Panoramas
CGSize(width: 210, height: 120),
CGSize(width: 97, height: 280),
CGSize(width: 120, height: 280),

// Article
CGSize(width: 8, height: 280),
CGSize(width: 120, height: 280),

// Irregular shapes
CGSize(width: 112, height: 280),
CGSize(width: 120, height: 280),
CGSize(width: 120, height: 280),
CGSize(width: 120, height: 280),

Expand Down

0 comments on commit a3dd3e4

Please sign in to comment.