From 7c4177bfd04d2e63f02e2b6ff11316d11baa3caa Mon Sep 17 00:00:00 2001 From: hustf <hustf@users.noreply.github.com> Date: Sun, 8 Nov 2020 18:12:44 +0100 Subject: [PATCH] Allow parsing of exponential number quantities --- test/conversion_promotion.jl | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/conversion_promotion.jl b/test/conversion_promotion.jl index f273354..28858bf 100644 --- a/test/conversion_promotion.jl +++ b/test/conversion_promotion.jl @@ -50,12 +50,13 @@ end end @testset "Quantity parse" begin -@test parse(Quantity{Float64}, "2.0kN") == 2.0kN -@test parse(Quantity{Int64}, "2 kN") == 2kN -@test parse(Quantity{Int64}, "2 [m]") == 2m -@test parse(Quantity{Float64}, "2 [m]") == 2.0m -@test parse(Quantity{Float64}, "2 [N m]") == 2.0Nm -lin = "2 [s]\t11364.56982421875 [N]\t-44553.50244140625 [N]\t-26.586366176605225 [N]\t0.0[N mm]\t0.0[N mm]\t0.0[N mm]\t1561.00350618362 [mm]\t-6072.3729133606 [mm]\t2825.15907287598 [mm]" -data = parse.(Quantity{Float64}, split(lin, '\t')) -@test data == [ 2.0s, 11364.56982421875N, -44553.50244140625N, -26.586366176605225N, 0.0mm∙N, 0.0mm∙N, 0.0mm∙N, 1561.00350618362mm, -6072.3729133606mm, 2825.15907287598mm] + @test parse(Quantity{Float64}, "2.0kN") == 2.0kN + @test parse(Quantity{Int64}, "2 kN") == 2kN + @test parse(Quantity{Int64}, "2 [m]") == 2m + @test parse(Quantity{Float64}, "2 [m]") == 2.0m + @test parse(Quantity{Float64}, "2 [N m]") == 2.0Nm + lin = "2 [s]\t11364.56982421875 [N]\t-44553.50244140625 [N]\t-26.586366176605225 [N]\t0.0[N mm]\t0.0[N mm]\t0.0[N mm]\t1561.00350618362 [mm]\t-6072.3729133606 [mm]\t2825.15907287598 [mm]" + data = parse.(Quantity{Float64}, split(lin, '\t')) + @test data == [ 2.0s, 11364.56982421875N, -44553.50244140625N, -26.586366176605225N, 0.0mm∙N, 0.0mm∙N, 0.0mm∙N, 1561.00350618362mm, -6072.3729133606mm, 2825.15907287598mm] + @test parse(Quantity{Float64}, "2.3E05m") == 230000m end