Skip to content

Commit

Permalink
Merge branch 'model-checking:main' into transmute_unchecked
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexLB99 authored Dec 3, 2024
2 parents a35f8a1 + d0d9de2 commit f813be8
Show file tree
Hide file tree
Showing 3 changed files with 503 additions and 16 deletions.
17 changes: 15 additions & 2 deletions library/core/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,20 @@ mod verify {
assert!(c_str.is_safe());
}
}


#[kani::proof]
#[kani::unwind(17)]
fn check_from_bytes_with_nul() {
const MAX_SIZE: usize = 16;
let string: [u8; MAX_SIZE] = kani::any();
let slice = kani::slice::any_slice_of_array(&string);

let result = CStr::from_bytes_with_nul(slice);
if let Ok(c_str) = result {
assert!(c_str.is_safe());
}
}

// pub const fn count_bytes(&self) -> usize
#[kani::proof]
#[kani::unwind(32)]
Expand Down Expand Up @@ -956,4 +969,4 @@ mod verify {
assert_eq!(expected_is_empty, c_str.is_empty());
assert!(c_str.is_safe());
}
}
}
Loading

0 comments on commit f813be8

Please sign in to comment.