diff --git a/Project.toml b/Project.toml index 08f8197..27d870b 100644 --- a/Project.toml +++ b/Project.toml @@ -9,6 +9,7 @@ HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" PyFormattedStrings = "5f89f4a4-a228-4886-b223-c468a82ed5b9" Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" +Reexport = "189a3867-3050-52da-a836-e630ba90ab69" [compat] julia = "1" diff --git a/src/AtomicAndPhysicalConstants.jl b/src/AtomicAndPhysicalConstants.jl index e70e355..0b9808b 100644 --- a/src/AtomicAndPhysicalConstants.jl +++ b/src/AtomicAndPhysicalConstants.jl @@ -4,7 +4,8 @@ using PyFormattedStrings using Dates using HTTP using JSON -using Unitful +using Reexport +@reexport using Unitful include("physical_constants.jl") include("atomic_isotopes.jl") diff --git a/test/runtests.jl b/test/runtests.jl index c07bf47..e888f38 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,30 +9,16 @@ end @testset "set_units.jl" begin - # constants should be undefined when setunits() in not called - @test !@isdefined c_light - @test !@isdefined m_electron - @test !@isdefined m_electron - @test !@isdefined m_proton - @test !@isdefined m_neutron - @test !@isdefined m_muon - @test !@isdefined m_helion - @test !@isdefined m_deuteron - @test !@isdefined m_pion_0 - @test !@isdefined m_pion_charged - @test !@isdefined r_e - @test !@isdefined e_charge - @test !@isdefined h_planck - @test !@isdefined mu_0_vac - @test !@isdefined eps_0_vac - @test !@isdefined kg_per_amu - @test !@isdefined eV_per_amu - @test !@isdefined N_avogadro - @test !@isdefined fine_structure - @test !@isdefined classical_radius_factor - @test !@isdefined r_p - @test !@isdefined h_bar_planck - @test !@isdefined kg_per_eV + # units should be available to users, including "amu" and "e" + # if not availble, an error would be thrown and the test would fail. + @test u"kg" == u"kg" + @test u"km" == u"km" + @test u"amu" == u"amu" + @test u"eV/c^2" == u"eV/c^2" + @test u"e" == u"e" + @test u"C" == u"C" + @test u"s" == u"s" + #setunits to default units setunits() @@ -161,11 +147,11 @@ end H = Species("H", 1, 1, 0, 0, 0) #mass should be in amu and charge in elementary charge - setunits(mass_unit = u"amu") + setunits(mass_unit=u"amu") @test massof(H) ≈ 1.0 @test chargeof(H) ≈ 1 - @test massof(H, "kg") ≈ 1.6605e-27 + @test massof(H, "kg") ≈ 1.6605390671738466e-27 @test chargeof(H, "C") ≈ 1.602176634e-19