File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ impl Weekday {
171171
172172impl fmt:: Display for Weekday {
173173 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
174- f. write_str ( match * self {
174+ f. pad ( match * self {
175175 Weekday :: Mon => "Mon" ,
176176 Weekday :: Tue => "Tue" ,
177177 Weekday :: Wed => "Wed" ,
@@ -331,6 +331,16 @@ mod tests {
331331 }
332332 }
333333
334+ #[ test]
335+ fn test_formatting_alignment ( ) {
336+ // No exhaustive testing here as we just delegate the
337+ // implementation to Formatter::pad. Just some basic smoke
338+ // testing to ensure that it's in fact being done.
339+ assert_eq ! ( format!( "{:x>7}" , Weekday :: Mon ) , "xxxxMon" ) ;
340+ assert_eq ! ( format!( "{:^7}" , Weekday :: Mon ) , " Mon " ) ;
341+ assert_eq ! ( format!( "{:Z<7}" , Weekday :: Mon ) , "MonZZZZ" ) ;
342+ }
343+
334344 #[ test]
335345 #[ cfg( feature = "serde" ) ]
336346 fn test_serde_serialize ( ) {
You can’t perform that action at this time.
0 commit comments