Add f formats to ifmt!

Currently the work just the same as the old `extfmt` versions
This commit is contained in:
Alex Crichton 2013-08-10 18:46:44 -07:00
parent 27b4d104c8
commit 36882b3d54
3 changed files with 54 additions and 12 deletions

View file

@ -172,11 +172,20 @@ pub fn main() {
t!(ifmt!("{:#o}", -1u8), "0o377");
// Signed combinations
t!(ifmt!("{:+5d}", 1), ~" +1");
t!(ifmt!("{:+5d}", -1), ~" -1");
t!(ifmt!("{:05d}", 1), ~"00001");
t!(ifmt!("{:05d}", -1), ~"-0001");
t!(ifmt!("{:+05d}", 1), ~"+0001");
t!(ifmt!("{:+05d}", -1), ~"-0001");
t!(ifmt!("{:+5d}", 1), " +1");
t!(ifmt!("{:+5d}", -1), " -1");
t!(ifmt!("{:05d}", 1), "00001");
t!(ifmt!("{:05d}", -1), "-0001");
t!(ifmt!("{:+05d}", 1), "+0001");
t!(ifmt!("{:+05d}", -1), "-0001");
// Some float stuff
t!(ifmt!("{:f}", 1.0f), "1");
t!(ifmt!("{:f}", 1.0f32), "1");
t!(ifmt!("{:f}", 1.0f64), "1");
t!(ifmt!("{:.3f}", 1.0f), "1.000");
t!(ifmt!("{:10.3f}", 1.0f), " 1.000");
t!(ifmt!("{:+10.3f}", 1.0f), " +1.000");
t!(ifmt!("{:+10.3f}", -1.0f), " -1.000");
}