init
This commit is contained in:
33
tests/memcpy.rs
Normal file
33
tests/memcpy.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#[test]
|
||||
pub fn test_memcpy() {
|
||||
let mut buffer1: Vec<u8> = Vec::with_capacity(0x1000);
|
||||
let mut buffer2: Vec<u8> = Vec::with_capacity(0x1000);
|
||||
|
||||
|
||||
// fill buffer1 with _random_ bytes
|
||||
let mut seed = 0x696969u64;
|
||||
for _ in 0..0x200 {
|
||||
buffer1.extend(seed.to_le_bytes());
|
||||
seed = seed.wrapping_mul(6364136223846793005).wrapping_add(1)
|
||||
}
|
||||
|
||||
// set buffer2's length to its capacity
|
||||
unsafe { buffer2.set_len(0x1000); }
|
||||
|
||||
// copy buffer1 to buffer2
|
||||
unsafe { xrt::memcpy(buffer2.as_mut_ptr(), buffer1.as_ptr(), 0x1000) };
|
||||
|
||||
assert_eq!(buffer1, buffer2);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user