Skip to content

Commit

Permalink
Test custom unit raises error
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Jun 26, 2023
1 parent e176d81 commit a365da0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ else
@safetestset "Unit tests" begin
include("unittests.jl")
end
end
end
13 changes: 13 additions & 0 deletions test/test_unitful.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,16 @@ for T in [DEFAULT_VALUE_TYPE, Float16, Float32, Float64], R in [DEFAULT_DIM_BASE

@test typeof(convert(DynamicQuantities.Dimensions, Unitful.dimension(x_unitful))) == DynamicQuantities.Dimensions{DEFAULT_DIM_BASE_TYPE}
end

module MyScaleUnit
using Unitful
@dimension(𝐒, "𝐒", Scale)
@refunit(scale, "scale", Scale, 𝐒, false)
end

Unitful.register(MyScaleUnit)

x = 1.0u"scale"
@test typeof(x) <: Unitful.Quantity{Float64, MyScaleUnit.𝐒}
@test_throws ErrorException convert(DynamicQuantities.Quantity, x)
# These are not supported because there is no SI equivalency

0 comments on commit a365da0

Please sign in to comment.