|
2 | 2 |
|
3 | 3 | use std::cell::RefCell;
|
4 | 4 | use std::fmt::{self, Write};
|
| 5 | +use std::ptr; |
5 | 6 |
|
6 | 7 | #[test]
|
7 | 8 | fn test_format() {
|
@@ -76,14 +77,14 @@ fn test_format_macro_interface() {
|
76 | 77 | t!(format!("{}", "foo"), "foo");
|
77 | 78 | t!(format!("{}", "foo".to_string()), "foo");
|
78 | 79 | if cfg!(target_pointer_width = "32") {
|
79 |
| - t!(format!("{:#p}", 0x1234 as *const isize), "0x00001234"); |
80 |
| - t!(format!("{:#p}", 0x1234 as *mut isize), "0x00001234"); |
| 80 | + t!(format!("{:#p}", ptr::invalid::<isize>(0x1234)), "0x00001234"); |
| 81 | + t!(format!("{:#p}", ptr::invalid_mut::<isize>(0x1234)), "0x00001234"); |
81 | 82 | } else {
|
82 |
| - t!(format!("{:#p}", 0x1234 as *const isize), "0x0000000000001234"); |
83 |
| - t!(format!("{:#p}", 0x1234 as *mut isize), "0x0000000000001234"); |
| 83 | + t!(format!("{:#p}", ptr::invalid::<isize>(0x1234)), "0x0000000000001234"); |
| 84 | + t!(format!("{:#p}", ptr::invalid_mut::<isize>(0x1234)), "0x0000000000001234"); |
84 | 85 | }
|
85 |
| - t!(format!("{:p}", 0x1234 as *const isize), "0x1234"); |
86 |
| - t!(format!("{:p}", 0x1234 as *mut isize), "0x1234"); |
| 86 | + t!(format!("{:p}", ptr::invalid::<isize>(0x1234)), "0x1234"); |
| 87 | + t!(format!("{:p}", ptr::invalid_mut::<isize>(0x1234)), "0x1234"); |
87 | 88 | t!(format!("{A:x}"), "aloha");
|
88 | 89 | t!(format!("{B:X}"), "adios");
|
89 | 90 | t!(format!("foo {} ☃☃☃☃☃☃", "bar"), "foo bar ☃☃☃☃☃☃");
|
|
0 commit comments