Skip to content

Commit ed70617

Browse files
committed
Add test for u8 align_offset
1 parent 62280b4 commit ed70617

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

tests/run-pass/aligned_utf8_check.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
fn main() {
2+
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!("{:?}", String::from_utf8_lossy(&y));
10+
11+
let mut x: Vec<u16> = unsafe { std::mem::transmute(y) };
12+
unsafe { x.set_len(N) };
13+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"AAAAAAAAAAAAAAAAAAAA"

0 commit comments

Comments
 (0)