|
| 1 | +import XCTest |
| 2 | + |
| 3 | +@testable import Darts |
| 4 | + |
| 5 | +class DartsTests: XCTestCase { |
| 6 | + let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false |
| 7 | + |
| 8 | + func testMissedTarget() { |
| 9 | + XCTAssertEqual(dartScore(x: -9, y: 9), 0) |
| 10 | + } |
| 11 | + |
| 12 | + func testOnTheOuterCircle() throws { |
| 13 | + try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 14 | + XCTAssertEqual(dartScore(x: 0, y: 10), 1) |
| 15 | + } |
| 16 | + |
| 17 | + func testOnTheMiddleCircle() throws { |
| 18 | + try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 19 | + XCTAssertEqual(dartScore(x: -5, y: 0), 5) |
| 20 | + } |
| 21 | + |
| 22 | + func testOnTheInnerCircle() throws { |
| 23 | + try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 24 | + XCTAssertEqual(dartScore(x: 0, y: -1), 10) |
| 25 | + } |
| 26 | + |
| 27 | + func testExactlyOnCenter() throws { |
| 28 | + try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 29 | + XCTAssertEqual(dartScore(x: 0, y: 0), 10) |
| 30 | + } |
| 31 | + |
| 32 | + func testNearTheCenter() throws { |
| 33 | + try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 34 | + XCTAssertEqual(dartScore(x: -0.1, y: -0.1), 10) |
| 35 | + } |
| 36 | + |
| 37 | + func testJustWithinTheInnerCircle() throws { |
| 38 | + try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 39 | + XCTAssertEqual(dartScore(x: 0.7, y: 0.7), 10) |
| 40 | + } |
| 41 | + |
| 42 | + func testJustOutsideTheInnerCircle() throws { |
| 43 | + try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 44 | + XCTAssertEqual(dartScore(x: 0.8, y: -0.8), 5) |
| 45 | + } |
| 46 | + |
| 47 | + func testJustWithinTheMiddleCircle() throws { |
| 48 | + try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 49 | + XCTAssertEqual(dartScore(x: -3.5, y: 3.5), 5) |
| 50 | + } |
| 51 | + |
| 52 | + func testJustOutsideTheMiddleCircle() throws { |
| 53 | + try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 54 | + XCTAssertEqual(dartScore(x: -3.6, y: -3.6), 1) |
| 55 | + } |
| 56 | + |
| 57 | + func testJustWithinTheOuterCircle() throws { |
| 58 | + try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 59 | + XCTAssertEqual(dartScore(x: -7, y: 7), 1) |
| 60 | + } |
| 61 | + |
| 62 | + func testJustOutsideTheOuterCircle() throws { |
| 63 | + try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 64 | + XCTAssertEqual(dartScore(x: 7.1, y: -7.1), 0) |
| 65 | + } |
| 66 | + |
| 67 | + func testAsymmetricPositionBetweenTheInnerAndMiddleCircles() throws { |
| 68 | + try XCTSkipIf(true && !runAll) // change true to false to run this test |
| 69 | + XCTAssertEqual(dartScore(x: 0.5, y: -4), 5) |
| 70 | + } |
| 71 | +} |
0 commit comments