Rollup merge of #146488 - ferrocene:pvdrz/improve-ptr-coverage, r=Mark-Simulacrum
Improve `core::ptr` coverage This PR improves the `core::ptr` coverage by adding a new test to `coretests` for the `<*const T>::is_aligned_to` method. r? libs
This commit is contained in:
@@ -489,6 +489,14 @@ fn is_aligned() {
|
|||||||
assert_ne!(ptr.is_aligned_to(8), ptr.wrapping_add(1).is_aligned_to(8));
|
assert_ne!(ptr.is_aligned_to(8), ptr.wrapping_add(1).is_aligned_to(8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[should_panic = "is_aligned_to: align is not a power-of-two"]
|
||||||
|
fn invalid_is_aligned() {
|
||||||
|
let data = 42;
|
||||||
|
let ptr: *const i32 = &data;
|
||||||
|
assert!(ptr.is_aligned_to(3));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn offset_from() {
|
fn offset_from() {
|
||||||
let mut a = [0; 5];
|
let mut a = [0; 5];
|
||||||
|
|||||||
Reference in New Issue
Block a user