// // CableTests.swift // CableTests // // Created by Stefan Lange-Hegermann on 11.09.25. // import Testing @testable import Cable struct CableTests { @Test func metricWireSizingUsesNearestStandardSize() async throws { let crossSection = ElectricalCalculations.recommendedCrossSection( length: 10, current: 5, voltage: 12, unitSystem: .metric ) #expect(crossSection == 4.0) let voltageDrop = ElectricalCalculations.voltageDrop( length: 10, current: 5, voltage: 12, unitSystem: .metric ) #expect(abs(voltageDrop - 0.425) < 0.001) let dropPercentage = ElectricalCalculations.voltageDropPercentage( length: 10, current: 5, voltage: 12, unitSystem: .metric ) #expect(abs(dropPercentage - 3.5417) < 0.001) let powerLoss = ElectricalCalculations.powerLoss( length: 10, current: 5, voltage: 12, unitSystem: .metric ) #expect(abs(powerLoss - 2.125) < 0.001) } @Test func imperialWireSizingMatchesExpectedGauge() async throws { let awg = ElectricalCalculations.recommendedCrossSection( length: 25, current: 15, voltage: 120, unitSystem: .imperial ) #expect(awg == 18.0) let voltageDrop = ElectricalCalculations.voltageDrop( length: 25, current: 15, voltage: 120, unitSystem: .imperial ) #expect(abs(voltageDrop - 4.722) < 0.01) let dropPercentage = ElectricalCalculations.voltageDropPercentage( length: 25, current: 15, voltage: 120, unitSystem: .imperial ) #expect(abs(dropPercentage - 3.935) < 0.01) let powerLoss = ElectricalCalculations.powerLoss( length: 25, current: 15, voltage: 120, unitSystem: .imperial ) #expect(abs(powerLoss - 70.83) < 0.05) } @Test func recommendedFuseRoundsUpToNearestStandardSize() async throws { #expect(ElectricalCalculations.recommendedFuse(forCurrent: 7.2) == 10) #expect(ElectricalCalculations.recommendedFuse(forCurrent: 59.0) == 80) } }