Skip to content

Commit 4b6119f

Browse files
test(tubular): add tests for radius input parsing and error cases
1 parent d226937 commit 4b6119f

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

test/unit_DataModel/test_Tubular.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,28 @@
8181
t5 = Tubular(0.01, 0.02, mmat)
8282
@test t5.material_props.rho isa Measurement
8383
end
84+
85+
@testset "Radius Input Parsing" begin
86+
import LineCableModels.DataModel: _normalize_radii
87+
# inner:Number, outer:Thickness
88+
@test _normalize_radii(Tubular, 0.01, Thickness(0.02)) == (0.01, 0.03)
89+
90+
# inner:Thickness, outer:Number
91+
rin, rex = _normalize_radii(Tubular, Thickness(0.002), 0.02)
92+
@test isapprox(rin, 0.018; atol=TEST_TOL)
93+
@test isapprox(rex, 0.02; atol=TEST_TOL)
94+
95+
96+
# inner:Thickness too large
97+
@test_throws ArgumentError _normalize_radii(Tubular, Thickness(0.03), 0.02)
98+
99+
# both Thickness → error
100+
@test_throws ArgumentError _normalize_radii(Tubular, Thickness(0.001), Thickness(0.002))
101+
102+
# diameter on either side collapses in parse:
103+
@test _normalize_radii(Tubular, Diameter(0.02), 0.03) == (0.01, 0.03)
104+
@test _normalize_radii(Tubular, 0.01, Diameter(0.02)) == (0.01, 0.01)
105+
106+
107+
end
84108
end

0 commit comments

Comments
 (0)