File tree 1 file changed +16
-3
lines changed
1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change 569
569
@test us " Constants.h" != us " h"
570
570
@test expand_units (us " Constants.h" ) == u " Constants.h"
571
571
572
- @test uconvert (us " nm" , 5e-9 u " m" ) ≈ (5e-9 u " m" |> uconvert (us " nm" )) ≈ 5 us " nm"
573
- @test_throws DimensionError uconvert (us " nm * J" , 5e-9 u " m" )
574
-
575
572
# Actually expands to:
576
573
@test dimension (us " Constants.h" )[:m ] == 2
577
574
@test dimension (us " Constants.h" )[:s ] == - 1
594
591
@test_throws " rad is not available as a symbol" sym5. rad
595
592
end
596
593
594
+ @testset " uconvert" begin
595
+ @test uconvert (us " nm" , 5e-9 u " m" ) ≈ (5e-9 u " m" |> uconvert (us " nm" )) ≈ 5 us " nm"
596
+ @test_throws DimensionError uconvert (us " nm * J" , 5e-9 u " m" )
597
+
598
+ q = 1.5 u " Constants.M_sun"
599
+ qs = uconvert (us " Constants.M_sun" , 5.0 * q)
600
+ @test qs ≈ 7.5 us " Constants.M_sun"
601
+ @test dimension (qs)[:kg ] == 0
602
+ @test dimension (qs)[:g ] == 0
603
+ @test dimension (qs)[:M_sun ] == 1
604
+ @test expand_units (qs) ≈ 5.0 * q
605
+
606
+ # Refuses to convert to non-unit quantities:
607
+ @test_throws ErrorException uconvert (1.2 us " m" , 1.0 u " m" )
608
+ end
609
+
597
610
@testset " Test ambiguities" begin
598
611
R = DEFAULT_DIM_BASE_TYPE
599
612
x = convert (R, 10 )
You can’t perform that action at this time.
0 commit comments