Move external tests to lib.rs
This commit is contained in:
parent
2d730cdf65
commit
7d5d20017b
|
@ -31,3 +31,27 @@ impl<'r, T> RawPtr<T> for Option<&'r T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::vk;
|
||||||
|
#[test]
|
||||||
|
fn test_ptr_chains() {
|
||||||
|
let mut variable_pointers = vk::PhysicalDeviceVariablePointerFeatures::builder();
|
||||||
|
let mut corner = vk::PhysicalDeviceCornerSampledImageFeaturesNV::builder();
|
||||||
|
let chain = vec![
|
||||||
|
&variable_pointers as *const _ as usize,
|
||||||
|
&corner as *const _ as usize,
|
||||||
|
];
|
||||||
|
let mut device_create_info = vk::DeviceCreateInfo::builder()
|
||||||
|
.push_next(&mut corner)
|
||||||
|
.push_next(&mut variable_pointers);
|
||||||
|
let chain2: Vec<usize> = unsafe {
|
||||||
|
vk::ptr_chain_iter(&mut device_create_info)
|
||||||
|
.skip(1)
|
||||||
|
.map(|ptr| ptr as usize)
|
||||||
|
.collect()
|
||||||
|
};
|
||||||
|
assert_eq!(chain, chain2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
4622
ash/src/vk.rs
4622
ash/src/vk.rs
File diff suppressed because it is too large
Load diff
|
@ -1,21 +0,0 @@
|
||||||
extern crate ash;
|
|
||||||
use ash::vk;
|
|
||||||
#[test]
|
|
||||||
fn test_ptr_chains() {
|
|
||||||
let mut variable_pointers = vk::PhysicalDeviceVariablePointerFeatures::builder();
|
|
||||||
let mut corner = vk::PhysicalDeviceCornerSampledImageFeaturesNV::builder();
|
|
||||||
let chain = vec![
|
|
||||||
&variable_pointers as *const _ as usize,
|
|
||||||
&corner as *const _ as usize,
|
|
||||||
];
|
|
||||||
let mut device_create_info = vk::DeviceCreateInfo::builder()
|
|
||||||
.push_next(&mut corner)
|
|
||||||
.push_next(&mut variable_pointers);
|
|
||||||
let chain2: Vec<usize> = unsafe {
|
|
||||||
vk::ptr_chain_iter(&mut device_create_info)
|
|
||||||
.skip(1)
|
|
||||||
.map(|ptr| ptr as usize)
|
|
||||||
.collect()
|
|
||||||
};
|
|
||||||
assert_eq!(chain, chain2);
|
|
||||||
}
|
|
|
@ -2200,7 +2200,7 @@ pub fn write_source_code(path: &Path) {
|
||||||
use std::os::raw::*;
|
use std::os::raw::*;
|
||||||
/// Iterates through the pointer chain. Includes the item that is passed into the function.
|
/// Iterates through the pointer chain. Includes the item that is passed into the function.
|
||||||
/// Stops at the last `BaseOutStructure` that has a null `p_next` field.
|
/// Stops at the last `BaseOutStructure` that has a null `p_next` field.
|
||||||
pub unsafe fn ptr_chain_iter<T>(
|
pub(crate) unsafe fn ptr_chain_iter<T>(
|
||||||
ptr: &mut T,
|
ptr: &mut T,
|
||||||
) -> impl Iterator<Item = *mut BaseOutStructure> {
|
) -> impl Iterator<Item = *mut BaseOutStructure> {
|
||||||
use std::ptr::null_mut;
|
use std::ptr::null_mut;
|
||||||
|
|
Loading…
Reference in a new issue