-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntests.jl
42 lines (34 loc) · 1.22 KB
/
runtests.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using SimpleConstants
using Test
@testset "SimpleConstants.jl" begin
λ = rand() # wavelength
@test 2πc₀/λ == 2π * c₀ / λ
@test ℎc₀/λ == ℎ * c₀ / λ
@test exp(i2π/3) == exp(im * 2π / 3)
@test exp(iπ/3) == exp(im * π / 3)
@test e⁻ < 0
@test e⁺ > 0
@test e⁻ + e⁺ == 0
@test 180° ≈ π
λ_inµm = rand()
E_ineV = meter2eV(λ_inµm * micro)
@test eV2meter(E_ineV) ≈ λ_inµm * micro
@test meter2eV(λ_inµm * micro) ≈ E_ineV
@test round(λ_inµm * E_ineV, digits=2) == 1.24 # (λ in µm) times (E in eV) is roughly 1.24
@test issorted(getfield.(SI_PREFIXES, :factor))
for prefix = SI_PREFIXES
x = π
@test x * prefix == x * prefix.factor
@test prefix * x == prefix.factor * x
@test x / prefix == x / prefix.factor
@test prefix / x == prefix.factor / x
@test x ^ prefix == x ^ prefix.factor
@test prefix ^ x == prefix.factor ^ x
xs = 1:10
@test x .* prefix == x .* prefix.factor
@test prefix .* x == prefix.factor .* x
@test x ./ prefix == x ./ prefix.factor
@test prefix ./ x == prefix.factor ./ x
@test "$prefix" == prefix.symbol
end
end