|
| 1 | +// |
| 2 | +// AdditiveArithmeticTests.swift |
| 3 | +// OpenGesturesTests |
| 4 | + |
| 5 | +import OpenCoreGraphicsShims |
| 6 | +import OpenGestures |
| 7 | +import Testing |
| 8 | + |
| 9 | +@Suite |
| 10 | +struct AdditiveArithmeticTests { |
| 11 | + @Test |
| 12 | + func doubleOperations() { |
| 13 | + #expect(Double.zero == 0.0) |
| 14 | + #expect(3.0 + 2.0 == 5.0) |
| 15 | + #expect(3.0 - 2.0 == 1.0) |
| 16 | + |
| 17 | + var value = 4.0 |
| 18 | + value += 1.5 |
| 19 | + #expect(value == 5.5) |
| 20 | + value -= 2.5 |
| 21 | + #expect(value == 3.0) |
| 22 | + } |
| 23 | + |
| 24 | + @Test |
| 25 | + func pointOperations() { |
| 26 | + #expect(CGPoint.zero == CGPoint(x: 0, y: 0)) |
| 27 | + #expect( |
| 28 | + CGPoint(x: 3, y: 4) + CGPoint(x: 1, y: 2) |
| 29 | + == CGPoint(x: 4, y: 6) |
| 30 | + ) |
| 31 | + #expect( |
| 32 | + CGPoint(x: 3, y: 4) - CGPoint(x: 1, y: 2) |
| 33 | + == CGPoint(x: 2, y: 2) |
| 34 | + ) |
| 35 | + |
| 36 | + var point = CGPoint(x: 2, y: 3) |
| 37 | + point += CGPoint(x: 4, y: 5) |
| 38 | + #expect(point == CGPoint(x: 6, y: 8)) |
| 39 | + point -= CGPoint(x: 1, y: 1) |
| 40 | + #expect(point == CGPoint(x: 5, y: 7)) |
| 41 | + } |
| 42 | + |
| 43 | + @Test |
| 44 | + func vectorAndSizeOperations() { |
| 45 | + #expect( |
| 46 | + CGVector(dx: 5, dy: 7) + CGVector(dx: 1, dy: 2) |
| 47 | + == CGVector(dx: 6, dy: 9) |
| 48 | + ) |
| 49 | + #expect( |
| 50 | + CGVector(dx: 5, dy: 7) - CGVector(dx: 1, dy: 2) |
| 51 | + == CGVector(dx: 4, dy: 5) |
| 52 | + ) |
| 53 | + |
| 54 | + #expect( |
| 55 | + CGSize(width: 8, height: 6) + CGSize(width: 2, height: 1) |
| 56 | + == CGSize(width: 10, height: 7) |
| 57 | + ) |
| 58 | + #expect( |
| 59 | + CGSize(width: 8, height: 6) - CGSize(width: 2, height: 1) |
| 60 | + == CGSize(width: 6, height: 5) |
| 61 | + ) |
| 62 | + } |
| 63 | +} |
0 commit comments