Skip to content

Commit

Permalink
Add test for u8 align_offset
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdrz committed Sep 11, 2019
1 parent 62280b4 commit ed70617
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/run-pass/aligned_utf8_check.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fn main() {
const N: usize = 10;

let x = vec![0x4141u16; N];

let mut y: Vec<u8> = unsafe { std::mem::transmute(x) };
unsafe { y.set_len(2 * N) };

println!("{:?}", String::from_utf8_lossy(&y));

let mut x: Vec<u16> = unsafe { std::mem::transmute(y) };
unsafe { x.set_len(N) };
}
1 change: 1 addition & 0 deletions tests/run-pass/aligned_utf8_check.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"AAAAAAAAAAAAAAAAAAAA"

0 comments on commit ed70617

Please sign in to comment.