Skip to content

Commit 3bb2814

Browse files
committed
Update tests
1 parent d9499af commit 3bb2814

9 files changed

Lines changed: 25 additions & 19 deletions

tests/unit/out/unsafe/cstring.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write};
77
use std::os::fd::{AsFd, FromRawFd, IntoRawFd};
88
use std::rc::Rc;
99
pub unsafe fn test_memcpy_0() {
10-
let src: [libc::c_char; 6] = libcc2rs::char_array(b"hello\0");
10+
let src: [libc::c_char; 6] = unsafe { ::std::mem::transmute(*b"hello\0") };
1111
let mut dst: [libc::c_char; 6] = [
1212
(0 as libc::c_char),
1313
(0 as libc::c_char),

tests/unit/out/unsafe/stdcopy_ostream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ unsafe fn main_0() -> i32 {
1616
let s = c"Hello, world!\n".as_ptr();
1717
std::slice::from_raw_parts(s, (0..).take_while(|&i| *s.add(i) != 0).count() + 1).to_vec()
1818
};
19-
let file: [libc::c_char; 25] = libcc2rs::char_array(b"test_stdcopy_ostream.txt\0");
19+
let file: [libc::c_char; 25] = unsafe { ::std::mem::transmute(*b"test_stdcopy_ostream.txt\0") };
2020
let mut ofs: ::std::fs::File =
2121
::std::fs::File::create(::std::ffi::CStr::from_ptr(file.as_ptr()).to_str().unwrap())
2222
.unwrap();

tests/unit/out/unsafe/string_h.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::io::{Read, Seek, Write};
77
use std::os::fd::{AsFd, FromRawFd, IntoRawFd};
88
use std::rc::Rc;
99
pub unsafe fn test_memcpy_0() {
10-
let src: [libc::c_char; 6] = libcc2rs::char_array(b"hello\0");
10+
let src: [libc::c_char; 6] = unsafe { ::std::mem::transmute(*b"hello\0") };
1111
let mut dst: [libc::c_char; 6] = [
1212
(0 as libc::c_char),
1313
(0 as libc::c_char),

tests/unit/out/unsafe/string_literals.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ unsafe fn main_0() -> i32 {
1717
let mut immutable_strings: [*const libc::c_char; 3] =
1818
[c"a".as_ptr(), c"b".as_ptr(), c"c".as_ptr()];
1919
let mut immutable_string: *const libc::c_char = c"hello".as_ptr();
20-
let mut mutable_string_arr: [libc::c_char; 9] = libcc2rs::char_array(b"papanasi\0");
21-
let immutable_string_arr: [libc::c_char; 9] = libcc2rs::char_array(b"papanasi\0");
20+
let mut mutable_string_arr: [libc::c_char; 9] =
21+
unsafe { ::std::mem::transmute(*b"papanasi\0") };
22+
let immutable_string_arr: [libc::c_char; 9] = unsafe { ::std::mem::transmute(*b"papanasi\0") };
2223
let mut immutable_empty: *const libc::c_char = c"".as_ptr();
2324
let mut mutable_empty_arr: [libc::c_char; 1] = [0 as libc::c_char; 1];
2425
let immutable_empty_arr: [libc::c_char; 1] = [0 as libc::c_char; 1];
@@ -30,7 +31,7 @@ unsafe fn main_0() -> i32 {
3031
(unsafe { foo_const_1(immutable_empty) });
3132
(unsafe { foo_const_1(immutable_empty_arr.as_ptr()) });
3233
let inited_through_init_list: [libc::c_char; 21] =
33-
libcc2rs::char_array(b"papanasi cu smantana\0");
34+
unsafe { ::std::mem::transmute(*b"papanasi cu smantana\0") };
3435
(unsafe { foo_const_1(inited_through_init_list.as_ptr()) });
3536
return 0;
3637
}

tests/unit/out/unsafe/string_literals_c.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ unsafe fn main_0() -> i32 {
2626
];
2727
let mut mutable_string: *mut libc::c_char = c"hello".as_ptr().cast_mut();
2828
let mut immutable_string: *const libc::c_char = (c"hello".as_ptr().cast_mut()).cast_const();
29-
let mut mutable_string_arr: [libc::c_char; 9] = libcc2rs::char_array(b"papanasi\0");
30-
let immutable_string_arr: [libc::c_char; 9] = libcc2rs::char_array(b"papanasi\0");
29+
let mut mutable_string_arr: [libc::c_char; 9] =
30+
unsafe { ::std::mem::transmute(*b"papanasi\0") };
31+
let immutable_string_arr: [libc::c_char; 9] = unsafe { ::std::mem::transmute(*b"papanasi\0") };
3132
let mut mutable_empty: *mut libc::c_char = c"".as_ptr().cast_mut();
3233
let mut immutable_empty: *const libc::c_char = (c"".as_ptr().cast_mut()).cast_const();
3334
let mut mutable_empty_arr: [libc::c_char; 1] = [0 as libc::c_char; 1];
@@ -46,7 +47,7 @@ unsafe fn main_0() -> i32 {
4647
(unsafe { foo_const_1((mutable_empty_arr.as_mut_ptr()).cast_const()) });
4748
(unsafe { foo_const_1(immutable_empty_arr.as_ptr()) });
4849
let inited_through_init_list: [libc::c_char; 21] =
49-
libcc2rs::char_array(b"papanasi cu smantana\0");
50+
unsafe { ::std::mem::transmute(*b"papanasi cu smantana\0") };
5051
(unsafe { foo_const_1(inited_through_init_list.as_ptr()) });
5152
return 0;
5253
}

tests/unit/out/unsafe/string_literals_concat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ unsafe fn main_0() -> i32 {
1616
assert!((((*joined.offset((0) as isize)) as i32) == (('a' as libc::c_char) as i32)));
1717
assert!((((*joined.offset((5) as isize)) as i32) == (('\n' as libc::c_char) as i32)));
1818
assert!((((*joined.offset((6) as isize)) as i32) == (('b' as libc::c_char) as i32)));
19-
let mut arr: [libc::c_char; 7] = libcc2rs::char_array(b"foobar\0");
19+
let mut arr: [libc::c_char; 7] = unsafe { ::std::mem::transmute(*b"foobar\0") };
2020
assert!(((arr[(0) as usize] as i32) == (('f' as libc::c_char) as i32)));
2121
assert!(((arr[(3) as usize] as i32) == (('b' as libc::c_char) as i32)));
2222
assert!(((arr[(5) as usize] as i32) == (('r' as libc::c_char) as i32)));

tests/unit/out/unsafe/string_literals_concat_c.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn main() {
1212
}
1313
}
1414
unsafe fn main_0() -> i32 {
15-
let mut arr: [libc::c_char; 7] = libcc2rs::char_array(b"foobar\0");
15+
let mut arr: [libc::c_char; 7] = unsafe { ::std::mem::transmute(*b"foobar\0") };
1616
assert!(((((arr[(0) as usize] as i32) == ('f' as i32)) as i32) != 0));
1717
assert!(((((arr[(3) as usize] as i32) == ('b' as i32)) as i32) != 0));
1818
assert!(((((arr[(5) as usize] as i32) == ('r' as i32)) as i32) != 0));

tests/unit/out/unsafe/string_literals_sized.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@ unsafe fn main_0() -> i32 {
1515
let mut empty_buf: [libc::c_char; 256] = [0 as libc::c_char; 256];
1616
assert!(((empty_buf[(0) as usize] as i32) == (('\0' as libc::c_char) as i32)));
1717
assert!(((empty_buf[(255) as usize] as i32) == (('\0' as libc::c_char) as i32)));
18-
let mut prefix_buf: [libc::c_char; 32] =
19-
libcc2rs::char_array(b"%\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
18+
let mut prefix_buf: [libc::c_char; 32] = unsafe {
19+
::std::mem::transmute(*b"%\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0")
20+
};
2021
assert!(((prefix_buf[(0) as usize] as i32) == (('%' as libc::c_char) as i32)));
2122
assert!(((prefix_buf[(1) as usize] as i32) == (('\0' as libc::c_char) as i32)));
2223
assert!(((prefix_buf[(31) as usize] as i32) == (('\0' as libc::c_char) as i32)));
23-
let mut short_buf: [libc::c_char; 16] = libcc2rs::char_array(b"hi\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
24+
let mut short_buf: [libc::c_char; 16] =
25+
unsafe { ::std::mem::transmute(*b"hi\0\0\0\0\0\0\0\0\0\0\0\0\0\0") };
2426
assert!(((short_buf[(0) as usize] as i32) == (('h' as libc::c_char) as i32)));
2527
assert!(((short_buf[(1) as usize] as i32) == (('i' as libc::c_char) as i32)));
2628
assert!(((short_buf[(2) as usize] as i32) == (('\0' as libc::c_char) as i32)));
2729
assert!(((short_buf[(15) as usize] as i32) == (('\0' as libc::c_char) as i32)));
28-
let mut exact_buf: [libc::c_char; 6] = libcc2rs::char_array(b"hello\0");
30+
let mut exact_buf: [libc::c_char; 6] = unsafe { ::std::mem::transmute(*b"hello\0") };
2931
assert!(((exact_buf[(0) as usize] as i32) == (('h' as libc::c_char) as i32)));
3032
assert!(((exact_buf[(4) as usize] as i32) == (('o' as libc::c_char) as i32)));
3133
assert!(((exact_buf[(5) as usize] as i32) == (('\0' as libc::c_char) as i32)));

tests/unit/out/unsafe/string_literals_sized_c.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@ unsafe fn main_0() -> i32 {
1515
let mut empty_buf: [libc::c_char; 256] = [0 as libc::c_char; 256];
1616
assert!(((((empty_buf[(0) as usize] as i32) == ('\0' as i32)) as i32) != 0));
1717
assert!(((((empty_buf[(255) as usize] as i32) == ('\0' as i32)) as i32) != 0));
18-
let mut prefix_buf: [libc::c_char; 32] =
19-
libcc2rs::char_array(b"%\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
18+
let mut prefix_buf: [libc::c_char; 32] = unsafe {
19+
::std::mem::transmute(*b"%\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0")
20+
};
2021
assert!(((((prefix_buf[(0) as usize] as i32) == ('%' as i32)) as i32) != 0));
2122
assert!(((((prefix_buf[(1) as usize] as i32) == ('\0' as i32)) as i32) != 0));
2223
assert!(((((prefix_buf[(31) as usize] as i32) == ('\0' as i32)) as i32) != 0));
23-
let mut short_buf: [libc::c_char; 16] = libcc2rs::char_array(b"hi\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
24+
let mut short_buf: [libc::c_char; 16] =
25+
unsafe { ::std::mem::transmute(*b"hi\0\0\0\0\0\0\0\0\0\0\0\0\0\0") };
2426
assert!(((((short_buf[(0) as usize] as i32) == ('h' as i32)) as i32) != 0));
2527
assert!(((((short_buf[(1) as usize] as i32) == ('i' as i32)) as i32) != 0));
2628
assert!(((((short_buf[(2) as usize] as i32) == ('\0' as i32)) as i32) != 0));
2729
assert!(((((short_buf[(15) as usize] as i32) == ('\0' as i32)) as i32) != 0));
28-
let mut exact_buf: [libc::c_char; 6] = libcc2rs::char_array(b"hello\0");
30+
let mut exact_buf: [libc::c_char; 6] = unsafe { ::std::mem::transmute(*b"hello\0") };
2931
assert!(((((exact_buf[(0) as usize] as i32) == ('h' as i32)) as i32) != 0));
3032
assert!(((((exact_buf[(4) as usize] as i32) == ('o' as i32)) as i32) != 0));
3133
assert!(((((exact_buf[(5) as usize] as i32) == ('\0' as i32)) as i32) != 0));

0 commit comments

Comments
 (0)