6 fn test_format_flags() {
7 // No residual flags left by pointer formatting
9 assert_eq!(format!("{:p} {:x}", p, 16), format!("{p:p} 10"));
11 assert_eq!(format!("{: >3}", 'a'), " a");
15 fn test_pointer_formats_data_pointer() {
18 assert_eq!(format!("{s:p}"), format!("{:p}", s.as_ptr()));
19 assert_eq!(format!("{b:p}"), format!("{:p}", b.as_ptr()));
23 fn test_estimated_capacity() {
24 assert_eq!(format_args!("").estimated_capacity(), 0);
25 assert_eq!(format_args!("{}", "").estimated_capacity(), 0);
26 assert_eq!(format_args!("Hello").estimated_capacity(), 5);
27 assert_eq!(format_args!("Hello, {}!", "").estimated_capacity(), 16);
28 assert_eq!(format_args!("{}, hello!", "World").estimated_capacity(), 0);
29 assert_eq!(format_args!("{}. 16-bytes piece", "World").estimated_capacity(), 32);
33 fn pad_integral_resets() {
36 impl core::fmt::Display for Bar {
37 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
39 f.pad_integral(true, "", "5")?;
44 assert_eq!(format!("{Bar:<03}"), "1 0051 ");