Skip to content

Commit

Permalink
Allow parsing of exponential number quantities
Browse files Browse the repository at this point in the history
  • Loading branch information
hustf authored Nov 8, 2020
1 parent 40bf125 commit 7c4177b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions test/conversion_promotion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.0mmN, 0.0mmN, 0.0mmN, 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.0mmN, 0.0mmN, 0.0mmN, 1561.00350618362mm, -6072.3729133606mm, 2825.15907287598mm]
@test parse(Quantity{Float64}, "2.3E05m") == 230000m
end

0 comments on commit 7c4177b

Please sign in to comment.