File tree 2 files changed +25
-0
lines changed
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ num-traits = { version = "0.2", optional = true }
13
13
serde = { version = " 1.0" , optional = true , features = [" derive" ] }
14
14
15
15
[dev-dependencies ]
16
+ euclid = " 0.22.11"
16
17
ron = " 0.8.0"
17
18
18
19
[features ]
Original file line number Diff line number Diff line change @@ -539,3 +539,27 @@ fn serialize() {
539
539
let serialized = ron:: to_string ( & Au ( 42 ) ) . unwrap ( ) ;
540
540
assert_eq ! ( ron:: from_str( & serialized) , Ok ( Au ( 42 ) ) ) ;
541
541
}
542
+
543
+ #[ cfg( feature = "num_traits" ) ]
544
+ #[ test]
545
+ fn euclid_cast_au_to_f32 ( ) {
546
+ use euclid:: default:: Size2D ;
547
+ let size_au: Size2D < Au > = Size2D :: new ( Au :: new ( 20 ) , Au :: new ( 30 ) ) ;
548
+ let size_f32_manual: Size2D < f32 > =
549
+ Size2D :: new ( Au :: new ( 20 ) . to_f32_px ( ) , Au :: new ( 30 ) . to_f32_px ( ) ) ;
550
+ let size_f32_cast: Size2D < f32 > = size_au. cast ( ) ;
551
+
552
+ assert_eq ! ( size_f32_manual, size_f32_cast) ;
553
+ }
554
+
555
+ #[ cfg( feature = "num_traits" ) ]
556
+ #[ test]
557
+ fn euclid_cast_f32_to_au ( ) {
558
+ use euclid:: default:: Size2D ;
559
+ let size_f32: Size2D < f32 > = Size2D :: new ( 3.1456 , 245.043656 ) ;
560
+ let size_au_manual: Size2D < Au > =
561
+ Size2D :: new ( Au :: from_f32_px ( 3.1456 ) , Au :: from_f32_px ( 245.043656 ) ) ;
562
+ let size_au_cast: Size2D < Au > = size_f32. cast ( ) ;
563
+
564
+ assert_eq ! ( size_au_manual, size_au_cast) ;
565
+ }
You can’t perform that action at this time.
0 commit comments