|
1 | | -import XCTest |
| 1 | +import Testing |
| 2 | +import Foundation |
| 3 | +import Numerics |
2 | 4 |
|
3 | 5 | @testable import FreelancerRates |
4 | 6 |
|
5 | | -let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false |
| 7 | +let RUNALL = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false |
6 | 8 |
|
7 | | -class TaskDailyRateFrom: XCTestCase { |
8 | | - func testdailyRateFromFor60() { |
9 | | - XCTAssertEqual(dailyRateFrom(hourlyRate: 60), 480.0, accuracy: 0.001) |
| 9 | +@Suite struct FreelancerRatesTests { |
| 10 | + @Test("Daily rate from hourly rate") |
| 11 | + func testTaskDailyRateFrom() { |
| 12 | + #expect(dailyRateFrom(hourlyRate: 60).isApproximatelyEqual(to: 480.0, relativeTolerance: 0.002)) |
10 | 13 | } |
11 | 14 |
|
12 | | - func testdailyRateFromFor16() throws { |
13 | | - try XCTSkipIf(true && !runAll) // change true to false to run this test |
14 | | - XCTAssertEqual(dailyRateFrom(hourlyRate: 16), 128.0, accuracy: 0.001) |
| 15 | + @Test("Daily rate from hourly rate with 16 as rate", .enabled(if: RUNALL)) |
| 16 | + func testTaskDailyRateFromFor16() { |
| 17 | + #expect(dailyRateFrom(hourlyRate: 16).isApproximatelyEqual(to: 128.0, relativeTolerance: 0.002)) |
15 | 18 | } |
16 | 19 |
|
17 | | - func testdailyRateFromFor25() throws { |
18 | | - try XCTSkipIf(true && !runAll) // change true to false to run this test |
19 | | - XCTAssertEqual(dailyRateFrom(hourlyRate: 25), 200.0, accuracy: 0.001) |
| 20 | + @Test("Daily rate from hourly rate with 25 as rate", .enabled(if: RUNALL)) |
| 21 | + func testTaskDailyRateFromFor25() { |
| 22 | + #expect(dailyRateFrom(hourlyRate: 25).isApproximatelyEqual(to: 200.0, relativeTolerance: 0.002)) |
20 | 23 | } |
21 | | -} |
22 | 24 |
|
23 | | -class TaskMonthlyRateFrom: XCTestCase { |
24 | | - func testmonthlyWithWholeResult() throws { |
25 | | - try XCTSkipIf(true && !runAll) // change true to false to run this test |
26 | | - XCTAssertEqual(monthlyRateFrom(hourlyRate: 80, withDiscount: 50), 7040, accuracy: 0.001) |
| 25 | + @Test("Montly rate with whole result", .enabled(if: RUNALL)) |
| 26 | + func testmonthlyWithWholeResult() { |
| 27 | + #expect(monthlyRateFrom(hourlyRate: 80, withDiscount: 50).isApproximatelyEqual(to: 7040, relativeTolerance: 0.001)) |
27 | 28 | } |
28 | 29 |
|
29 | | - func testmonthlyRoundDown() throws { |
30 | | - try XCTSkipIf(true && !runAll) // change true to false to run this test |
31 | | - XCTAssertEqual(monthlyRateFrom(hourlyRate: 77, withDiscount: 10.5), 12129, accuracy: 0.001) |
| 30 | + @Test("Montly rate round down", .enabled(if: RUNALL)) |
| 31 | + func testmonthlyRoundDown() { |
| 32 | + #expect(monthlyRateFrom(hourlyRate: 77, withDiscount: 10.5).isApproximatelyEqual(to: 12129, relativeTolerance: 0.001)) |
32 | 33 | } |
33 | 34 |
|
34 | | - func testmonthlyRoundUp() throws { |
35 | | - try XCTSkipIf(true && !runAll) // change true to false to run this test |
36 | | - XCTAssertEqual(monthlyRateFrom(hourlyRate: 80, withDiscount: 10.5), 12602, accuracy: 0.001) |
| 35 | + @Test("Montly rate round up", .enabled(if: RUNALL)) |
| 36 | + func testmonthlyRoundUp() { |
| 37 | + #expect(monthlyRateFrom(hourlyRate: 80, withDiscount: 10.5).isApproximatelyEqual(to: 12602, relativeTolerance: 0.001)) |
37 | 38 | } |
38 | | -} |
39 | 39 |
|
40 | | -class TaskWorkdaysIn: XCTestCase { |
41 | | - func testworkdaysInSmallBudget() throws { |
42 | | - try XCTSkipIf(true && !runAll) // change true to false to run this test |
43 | | - XCTAssertEqual( |
44 | | - workdaysIn(budget: 1000, hourlyRate: 50, withDiscount: 10), 2.0, accuracy: 0.001) |
| 40 | + |
| 41 | + @Test("Workdays in small budget", .enabled(if: RUNALL)) |
| 42 | + func testworkdaysInSmallBudget() { |
| 43 | + #expect(workdaysIn(budget: 1000, hourlyRate: 50, withDiscount: 10).isApproximatelyEqual(to: 2.0, relativeTolerance: 0.001)) |
45 | 44 | } |
46 | 45 |
|
47 | | - func testworkdaysInMediumBudget() throws { |
48 | | - try XCTSkipIf(true && !runAll) // change true to false to run this test |
49 | | - XCTAssertEqual( |
50 | | - workdaysIn(budget: 5000, hourlyRate: 60, withDiscount: 10), 11.0, accuracy: 0.001) |
| 46 | + @Test("Workdays in medium budget", .enabled(if: RUNALL)) |
| 47 | + func testworkdaysInMediumBudget() { |
| 48 | + #expect(workdaysIn(budget: 5000, hourlyRate: 60, withDiscount: 10).isApproximatelyEqual(to: 11.0, relativeTolerance: 0.001)) |
51 | 49 | } |
52 | 50 |
|
53 | | - func testworkdaysLargebudget() throws { |
54 | | - try XCTSkipIf(true && !runAll) // change true to false to run this test |
55 | | - XCTAssertEqual( |
56 | | - workdaysIn(budget: 25_000, hourlyRate: 80, withDiscount: 10), 43.0, accuracy: 0.001) |
| 51 | + @Test("Workdays large budget", .enabled(if: RUNALL)) |
| 52 | + func testworkdaysLargebudget() { |
| 53 | + #expect(workdaysIn(budget: 25_000, hourlyRate: 80, withDiscount: 10).isApproximatelyEqual(to: 43.0, relativeTolerance: 0.001)) |
57 | 54 | } |
58 | 55 |
|
59 | | - func testworkdaysShouldRound() throws { |
60 | | - try XCTSkipIf(true && !runAll) // change true to false to run this test |
61 | | - XCTAssertEqual( |
62 | | - workdaysIn(budget: 20000, hourlyRate: 80, withDiscount: 11), 35.0, accuracy: 0.001) |
| 56 | + @Test("Workdays should round", .enabled(if: RUNALL)) |
| 57 | + func testworkdaysShouldRound() { |
| 58 | + #expect(workdaysIn(budget: 20000, hourlyRate: 80, withDiscount: 11).isApproximatelyEqual(to: 35.0, relativeTolerance: 0.001)) |
63 | 59 | } |
64 | 60 |
|
65 | | - func testworkdaysShouldNotRoundToNearstInteger() throws { |
66 | | - try XCTSkipIf(true && !runAll) // change true to false to run this test |
67 | | - XCTAssertEqual( |
68 | | - workdaysIn(budget: 25_000, hourlyRate: 80, withDiscount: 11), 43.0, accuracy: 0.001) |
| 61 | + @Test("Workdays should not round to nearst integer", .enabled(if: RUNALL)) |
| 62 | + func testworkdaysShouldNotRoundToNearstInteger() { |
| 63 | + #expect(workdaysIn(budget: 25_000, hourlyRate: 80, withDiscount: 11).isApproximatelyEqual(to: 43.0, relativeTolerance: 0.001)) |
69 | 64 | } |
70 | 65 | } |
0 commit comments