Skip to content

Commit 0a14c1d

Browse files
committed
Update tests
1 parent 4bb7665 commit 0a14c1d

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

‎tests/unit/out/refcount/string.rs‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,33 @@ fn main_0() -> i32 {
292292
.unwrap_or(usize::MAX)
293293
});
294294
assert!((pos == ((-1_i64 as u64) as usize)));
295+
pos = {
296+
let __hay = &result[..result.len().saturating_sub(1)];
297+
Ptr::<i8>::from_string_literal(b"f").with_c_str(|__needle| {
298+
(0_usize..=__hay.len().saturating_sub(__needle.len()))
299+
.find(|&__i| __hay[__i..].starts_with(__needle))
300+
.unwrap_or(usize::MAX)
301+
})
302+
};
303+
assert!((pos == 5_usize));
304+
pos = {
305+
let __hay = &result[..result.len().saturating_sub(1)];
306+
Ptr::<i8>::from_string_literal(b"oo").with_c_str(|__needle| {
307+
(0_usize..=__hay.len().saturating_sub(__needle.len()))
308+
.find(|&__i| __hay[__i..].starts_with(__needle))
309+
.unwrap_or(usize::MAX)
310+
})
311+
};
312+
assert!((pos == 6_usize));
313+
pos = {
314+
let __hay = &result[..result.len().saturating_sub(1)];
315+
Ptr::<i8>::from_string_literal(b"x").with_c_str(|__needle| {
316+
(0_usize..=__hay.len().saturating_sub(__needle.len()))
317+
.find(|&__i| __hay[__i..].starts_with(__needle))
318+
.unwrap_or(usize::MAX)
319+
})
320+
};
321+
assert!((pos == ((-1_i64 as u64) as usize)));
295322
let string_to_cast: Value<Vec<i8>> = Rc::new(RefCell::new({
296323
let mut __bytes = Ptr::<i8>::from_string_literal(b"cast").to_c_bytes();
297324
__bytes.push(0);

‎tests/unit/out/unsafe/string.rs‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,30 @@ unsafe fn main_0() -> i32 {
312312
None => usize::MAX,
313313
};
314314
assert!(((pos) == ((-1_i64 as u64) as usize)));
315+
pos = {
316+
let __hay = &result[..result.len() - 1];
317+
let __needle = ::std::slice::from_raw_parts(c"f".as_ptr(), libc::strlen(c"f".as_ptr()));
318+
(0_usize..=__hay.len().saturating_sub(__needle.len()))
319+
.find(|&__i| __hay[__i..].starts_with(__needle))
320+
.unwrap_or(usize::MAX)
321+
};
322+
assert!(((pos) == (5_usize)));
323+
pos = {
324+
let __hay = &result[..result.len() - 1];
325+
let __needle = ::std::slice::from_raw_parts(c"oo".as_ptr(), libc::strlen(c"oo".as_ptr()));
326+
(0_usize..=__hay.len().saturating_sub(__needle.len()))
327+
.find(|&__i| __hay[__i..].starts_with(__needle))
328+
.unwrap_or(usize::MAX)
329+
};
330+
assert!(((pos) == (6_usize)));
331+
pos = {
332+
let __hay = &result[..result.len() - 1];
333+
let __needle = ::std::slice::from_raw_parts(c"x".as_ptr(), libc::strlen(c"x".as_ptr()));
334+
(0_usize..=__hay.len().saturating_sub(__needle.len()))
335+
.find(|&__i| __hay[__i..].starts_with(__needle))
336+
.unwrap_or(usize::MAX)
337+
};
338+
assert!(((pos) == ((-1_i64 as u64) as usize)));
315339
let mut string_to_cast: Vec<libc::c_char> = {
316340
let s = c"cast".as_ptr();
317341
std::slice::from_raw_parts(s, (0..).take_while(|&i| *s.add(i) != 0).count() + 1).to_vec()

0 commit comments

Comments
 (0)