File tree 2 files changed +27
-0
lines changed
2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -516,3 +516,25 @@ impl fmt::Display for NumberParts {
516
516
write ! ( fmt, "{}" , self . format( "n u w" ) )
517
517
}
518
518
}
519
+
520
+ #[ cfg( test) ]
521
+ mod tests {
522
+ use crate :: types:: { BaseUnit , Number , Numeric } ;
523
+
524
+ #[ test]
525
+ fn test_fmt ( ) {
526
+ let number = Number :: new_unit ( Numeric :: from ( 42 ) , BaseUnit :: new ( "m" ) ) ;
527
+ let ctx = crate :: simple_context ( ) . unwrap ( ) ;
528
+ let parts = number. to_parts ( & ctx) ;
529
+
530
+ assert_eq ! ( parts. format( "e" ) , "42" ) ;
531
+ assert_eq ! ( parts. format( "a" ) , "" ) ;
532
+ assert_eq ! ( parts. format( "u" ) , "meter" ) ;
533
+ assert_eq ! ( parts. format( "q" ) , "length" ) ;
534
+ assert_eq ! ( parts. format( "w" ) , "(length)" ) ;
535
+ assert_eq ! ( parts. format( "d" ) , "m" ) ;
536
+ assert_eq ! ( parts. format( "D" ) , "m" ) ;
537
+ assert_eq ! ( parts. format( "p" ) , "(length; m)" ) ;
538
+ assert_eq ! ( parts. format( "VALUE: e" ) , "VALUE: 42" ) ;
539
+ }
540
+ }
Original file line number Diff line number Diff line change @@ -871,3 +871,8 @@ fn conversion_to_digit_errors() {
871
871
"Conversion to digits of US/Pacific is not defined" ,
872
872
) ;
873
873
}
874
+
875
+ #[ test]
876
+ fn test_conversion_multiples ( ) {
877
+ test ( "floppydisk to 512B" , "2880 * 512 byte (information)" ) ;
878
+ }
You can’t perform that action at this time.
0 commit comments