navigation fixed

This commit is contained in:
Stefan Lange-Hegermann
2025-09-16 22:00:04 +02:00
parent 177d5c350e
commit e081ca8b3b
5 changed files with 433 additions and 215 deletions

View File

@@ -10,8 +10,41 @@ import Testing
struct CableTests {
@Test func example() async throws {
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
@Test func metricWireSizingUsesNearestStandardSize() async throws {
let calculator = CableCalculator()
calculator.voltage = 12
calculator.current = 5
calculator.length = 10 // meters
let crossSection = calculator.recommendedCrossSection(for: .metric)
#expect(crossSection == 4.0)
let voltageDrop = calculator.voltageDrop(for: .metric)
#expect(abs(voltageDrop - 0.425) < 0.001)
let dropPercentage = calculator.voltageDropPercentage(for: .metric)
#expect(abs(dropPercentage - 3.5417) < 0.001)
let powerLoss = calculator.powerLoss(for: .metric)
#expect(abs(powerLoss - 2.125) < 0.001)
}
@Test func imperialWireSizingMatchesExpectedGauge() async throws {
let calculator = CableCalculator()
calculator.voltage = 120
calculator.current = 15
calculator.length = 25 // feet
let awg = calculator.recommendedCrossSection(for: .imperial)
#expect(awg == 18.0)
let voltageDrop = calculator.voltageDrop(for: .imperial)
#expect(abs(voltageDrop - 4.722) < 0.01)
let dropPercentage = calculator.voltageDropPercentage(for: .imperial)
#expect(abs(dropPercentage - 3.935) < 0.01)
let powerLoss = calculator.powerLoss(for: .imperial)
#expect(abs(powerLoss - 70.83) < 0.05)
}
}