This commit is contained in:
2024-01-26 21:03:30 -05:00
commit 7c2ba320fa
13 changed files with 547 additions and 0 deletions

33
tests/memcpy.rs Normal file
View 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);
}