Skip to content

Commit 497de53

Browse files
committed
Update align_offset tests
1 parent 881929f commit 497de53

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

tests/run-pass/aligned_utf8_check.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
fn main() {
22
const N: usize = 10;
3-
4-
let x = vec![0x4141u16; N];
5-
6-
let mut y: Vec<u8> = unsafe { std::mem::transmute(x) };
7-
unsafe { y.set_len(2 * N) };
8-
9-
println!("{:?}", std::str::from_utf8(&y).unwrap());
10-
11-
let mut x: Vec<u16> = unsafe { std::mem::transmute(y) };
12-
unsafe { x.set_len(N) };
3+
let vec = vec![0x4141414141414141u64; N];
4+
let content = unsafe { std::slice::from_raw_parts(vec.as_ptr() as *const u8, 8 * N) };
5+
println!("{:?}", std::str::from_utf8(content).unwrap());
136
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"AAAAAAAAAAAAAAAAAAAA"
1+
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
assert_eq!(2, (2 as *const i8).align_offset(4));
3+
}

0 commit comments

Comments
 (0)