Skip to content

Commit b03b6b3

Browse files
test(validation): add unit tests for validation module
1 parent 9ffe1ab commit b03b6b3

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@testitem "Validation(Tubular): rule order unit test" setup = [defaults] begin
2+
# Use fully-qualified names; do not add extra `using` here.
3+
V = LineCableModels.Validation
4+
T = LineCableModels.DataModel.Tubular
5+
M = LineCableModels.Materials.Material
6+
7+
r = V._rules(T)
8+
9+
expected = (
10+
V.Normalized(:radius_in), V.Normalized(:radius_ext),
11+
V.Finite(:radius_in), V.Nonneg(:radius_in),
12+
V.Finite(:radius_ext), V.Nonneg(:radius_ext),
13+
V.Less(:radius_in, :radius_ext),
14+
V.Finite(:temperature),
15+
V.IsA{M}(:material_props),
16+
)
17+
18+
if r != expected
19+
@error "[Validation] Rule set for Tubular is wrong. Someone ‘helpfully’ changed the bundle order or duplicated rules.\n" *
20+
"Expected exact structural equality with the generated bundle. Fix your traits/extra_rules and stop being clever."
21+
@show expected
22+
@show r
23+
end
24+
25+
@test r == expected
26+
end

0 commit comments

Comments
 (0)