diff options
Diffstat (limited to 'src/libcoretest')
| -rw-r--r-- | src/libcoretest/fmt/mod.rs | 10 | ||||
| -rw-r--r-- | src/libcoretest/lib.rs | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/libcoretest/fmt/mod.rs b/src/libcoretest/fmt/mod.rs index ed33596e1c2..5d204c7d523 100644 --- a/src/libcoretest/fmt/mod.rs +++ b/src/libcoretest/fmt/mod.rs @@ -28,3 +28,13 @@ fn test_pointer_formats_data_pointer() { assert_eq!(format!("{:p}", s), format!("{:p}", s.as_ptr())); assert_eq!(format!("{:p}", b), format!("{:p}", b.as_ptr())); } + +#[test] +fn test_estimated_capacity() { + assert_eq!(format_args!("").estimated_capacity(), 0); + assert_eq!(format_args!("{}", "").estimated_capacity(), 0); + assert_eq!(format_args!("Hello").estimated_capacity(), 5); + assert_eq!(format_args!("Hello, {}!", "").estimated_capacity(), 16); + assert_eq!(format_args!("{}, hello!", "World").estimated_capacity(), 0); + assert_eq!(format_args!("{}. 16-bytes piece", "World").estimated_capacity(), 32); +} diff --git a/src/libcoretest/lib.rs b/src/libcoretest/lib.rs index 87f3afd6889..e06b757691e 100644 --- a/src/libcoretest/lib.rs +++ b/src/libcoretest/lib.rs @@ -34,6 +34,7 @@ #![feature(ordering_chaining)] #![feature(ptr_unaligned)] #![feature(move_cell)] +#![feature(fmt_internals)] extern crate core; extern crate test; |
