Sha256: 738bf3b76d5a4c699c08ab678c8e9dcf815bc963fe031424cc0de8209d49c6a4

Contents?: true

Size: 1.18 KB

Versions: 12

Compression:

Stored size: 1.18 KB

Contents

class CGSize
  def close?(to, delta)
    width.close?(to.width, delta) && height.close?(to.height, delta)
  end
end

describe "Sizes" do
  delta = 0.0001

  it "CGSize scaling" do
    CGSizeMake(100, 100).scale_to_fit(CGSizeMake(10, 10)).should.close CGSizeMake(10, 10), delta
    CGSizeMake(200, 100).scale_to_fit(CGSizeMake(15, 15)).should.close CGSizeMake(15, 7.5), delta
    CGSizeMake(100, 100).scale_to_fill(CGSizeMake(10, 10)).should.close CGSizeMake(10, 10), delta
    CGSizeMake(200, 100).scale_to_fill(CGSizeMake(15, 15)).should.close CGSizeMake(30, 15), delta
    CGSizeMake(10, 10).scale_to_fit(CGSizeMake(100, 100)).should.close CGSizeMake(100, 100), delta
    CGSizeMake(10, 5).scale_to_fit(CGSizeMake(100, 100)).should.close CGSizeMake(100, 50), delta
    CGSizeMake(10, 10).scale_to_fill(CGSizeMake(100, 100)).should.close CGSizeMake(100, 100), delta
    CGSizeMake(10, 5).scale_to_fill(CGSizeMake(100, 100)).should.close CGSizeMake(200, 100), delta

    s = CGSizeMake(200, 100)
    s.scale_to_fit!(CGSizeMake(15, 15))
    s.should.close CGSizeMake(15, 7.5), delta

    s = CGSizeMake(10, 5)
    s.scale_to_fill!(CGSizeMake(100, 100))
    s.should.close CGSizeMake(200, 100), delta
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
purplish-frame-0.0.12 spec/non-ui/cg_size.spec.rb
purplish-frame-0.0.11 spec/non-ui/cg_size.spec.rb
purplish-frame-0.0.10 spec/non-ui/cg_size.spec.rb
purplish-frame-0.0.9 spec/non-ui/cg_size.spec.rb
purplish-frame-0.0.8 spec/non-ui/cg_size.spec.rb
purplish-frame-0.0.7 spec/non-ui/cg_size.spec.rb
purplish-frame-0.0.6 spec/non-ui/cg_size.spec.rb
purplish-frame-0.0.5 spec/non-ui/cg_size.spec.rb
purplish-frame-0.0.4 spec/non-ui/cg_size.spec.rb
purplish-frame-0.0.3 spec/non-ui/cg_size.spec.rb
purplish-frame-0.0.2 spec/cg_size.spec.rb
purplish-frame-0.0.1 spec/cg_size.spec.rb