#![allow(dead_code)]
use zerodds_rtps::wire_types::{EntityId, Guid, GuidPrefix};
pub const TEST_WRITER_KEY: [u8; 3] = [0x10, 0x20, 0x30];
pub const TEST_READER_KEY: [u8; 3] = [0xA0, 0xB0, 0xC0];
#[must_use]
pub fn test_writer_guid() -> Guid {
Guid::new(
GuidPrefix::from_bytes([1; 12]),
EntityId::user_writer_with_key(TEST_WRITER_KEY),
)
}
#[must_use]
pub fn test_reader_guid() -> Guid {
Guid::new(
GuidPrefix::from_bytes([2; 12]),
EntityId::user_reader_with_key(TEST_READER_KEY),
)
}
#[must_use]
pub fn pattern_for(sn: usize, len: usize) -> Vec<u8> {
let seed = (sn as u32).wrapping_mul(0x9E37_79B1);
(0..len)
.map(|i| (seed.wrapping_add(i as u32) & 0xFF) as u8)
.collect()
}
#[derive(Debug, Clone)]
pub struct XorShift32(pub u32);
impl XorShift32 {
#[must_use]
pub fn new(seed: u32) -> Self {
Self(if seed == 0 { 0xDEAD_BEEF } else { seed })
}
pub fn next_u32(&mut self) -> u32 {
let mut x = self.0;
x ^= x << 13;
x ^= x >> 17;
x ^= x << 5;
self.0 = x;
x
}
}