Skip to content

Commit

Permalink
Add tests for logarithmic quantities
Browse files Browse the repository at this point in the history
  • Loading branch information
sostock committed May 22, 2024
1 parent f79bbaa commit 4528b2c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,17 @@ end
@test convert(Float64, u"10dB_p") === 10.0
@test convert(Float64, u"20dB_rp") === 10.0

for L = (40u"dB_rp", 20u"dB_p", 40u"dBFS")
for U = (NoUnits, FixedUnits(NoUnits), ContextUnits(NoUnits, m/mm))
@test convert(Quantity{Int,NoDims,typeof(U)}, L) === Quantity{Int,NoDims,typeof(U)}(100)
@test convert(Quantity{Int,NoDims,typeof(U)}, L/rad) === Quantity{Int,NoDims,typeof(U)}(100)
end
@test convert(Quantity{Int}, L) === Quantity{Int,NoDims,typeof(NoUnits)}(100)
@test convert(Quantity{Int}, L/rad) === 100/rad
@test convert(Quantity{Int,NoDims}, L) === Quantity{Int,NoDims,typeof(NoUnits)}(100)
@test convert(Quantity{Int,NoDims}, L/rad) === 100/rad
end

@test isapprox(uconvertrp(NoUnits, 6.02dB), 2.0, atol=0.001)
@test uconvertrp(NoUnits, 1Np) MathConstants.e
@test uconvertrp(Np, MathConstants.e) == 1Np
Expand Down

0 comments on commit 4528b2c

Please sign in to comment.