move a ui test to coretests unit test
It only tests the usage and formatting of `fmt::Pointer`.
This commit is contained in:
parent
4f14395c37
commit
54062cff4c
2 changed files with 19 additions and 24 deletions
|
|
@ -76,6 +76,25 @@ fn test_fmt_debug_of_mut_reference() {
|
|||
assert_eq!(format!("{:?}", &mut x), "0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fmt_pointer() {
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
let p: *const u8 = std::ptr::null();
|
||||
let rc = Rc::new(1usize);
|
||||
let arc = Arc::new(1usize);
|
||||
let b = Box::new("hi");
|
||||
|
||||
let _ = format!("{rc:p}{arc:p}{b:p}");
|
||||
|
||||
if cfg!(target_pointer_width = "32") {
|
||||
assert_eq!(format!("{:#p}", p), "0x00000000");
|
||||
} else {
|
||||
assert_eq!(format!("{:#p}", p), "0x0000000000000000");
|
||||
}
|
||||
assert_eq!(format!("{:p}", p), "0x0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_default_write_impls() {
|
||||
use core::fmt::Write;
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
//@ run-pass
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
fn main() {
|
||||
let p: *const u8 = ptr::null();
|
||||
let rc = Rc::new(1usize);
|
||||
let arc = Arc::new(1usize);
|
||||
let b = Box::new("hi");
|
||||
|
||||
let _ = format!("{:p}{:p}{:p}",
|
||||
rc, arc, b);
|
||||
|
||||
if cfg!(target_pointer_width = "32") {
|
||||
assert_eq!(format!("{:#p}", p),
|
||||
"0x00000000");
|
||||
} else {
|
||||
assert_eq!(format!("{:#p}", p),
|
||||
"0x0000000000000000");
|
||||
}
|
||||
assert_eq!(format!("{:p}", p),
|
||||
"0x0");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue