forked from WeTransfer/WeScan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCGRectTests.swift
34 lines (25 loc) · 1.01 KB
/
CGRectTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
// CGRectTests.swift
// WeScanTests
//
// Created by Boris Emorine on 2/26/18.
// Copyright © 2018 WeTransfer. All rights reserved.
//
import XCTest
@testable import WeScan
final class CGRectTests: XCTestCase {
func testScaleAndCenter() {
var rect = CGRect(x: 0.0, y: 0.0, width: 100.0, height: 100.0)
rect = rect.scaleAndCenter(withRatio: 0.5)
var expectedRect = CGRect(x: 25.0, y: 25.0, width: 50.0, height: 50.0)
XCTAssert(rect == expectedRect)
rect = CGRect(x: 100.0, y: 100.0, width: 200.0, height: 200.0)
rect = rect.scaleAndCenter(withRatio: 0.75)
expectedRect = CGRect(x: 125.0, y: 125.0, width: 150.0, height: 150.0)
XCTAssert(rect == expectedRect)
rect = CGRect(x: 100.0, y: 100.0, width: 200.0, height: 200.0)
rect = rect.scaleAndCenter(withRatio: 2.0)
expectedRect = CGRect(x: 0.0, y: 0.0, width: 400.0, height: 400.0)
XCTAssert(rect == expectedRect)
}
}