From 04b20bef206f79b1f13425b433d5150a38516418 Mon Sep 17 00:00:00 2001 From: Douglas Greenshields Date: Thu, 18 Apr 2024 15:19:20 +0100 Subject: [PATCH] add explicit port of thermal bridging unit tests --- src/core/space_heat_demand/thermal_bridge.rs | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/core/space_heat_demand/thermal_bridge.rs b/src/core/space_heat_demand/thermal_bridge.rs index 99d9cc8..ca46992 100644 --- a/src/core/space_heat_demand/thermal_bridge.rs +++ b/src/core/space_heat_demand/thermal_bridge.rs @@ -142,4 +142,33 @@ mod test { 6.7 ); } + + #[rstest] + pub fn test_heat_trans_coeff_for_linear() { + let tb = ThermalBridge::Linear { + linear_thermal_transmittance: 0.28, + length: 5.0, + }; + assert_eq!( + round_by_precision(heat_transfer_coefficient_for_thermal_bridge(&tb), 1e6), + 1.4, + "incorrect heat transfer coefficient returned" + ); + } + + #[rstest] + pub fn test_heat_trans_coeff_for_point() { + let tb = ThermalBridge::Point { + heat_transfer_coefficient: 1.4, + }; + assert_eq!( + heat_transfer_coefficient_for_thermal_bridge(&tb), + 1.4, + "incorrect heat transfer coefficient returned" + ); + } + + fn round_by_precision(src: f64, precision: f64) -> f64 { + (precision * src).round() / precision + } }