use crate::{UUID, UUID_BYTES};
impl UUID {
#[must_use]
pub const fn max() -> Self {
Self {
bytes: [0xFF; UUID_BYTES],
}
}
}
#[cfg(test)]
mod tests {
use crate::{UUID, UUID_BYTES};
#[test]
fn test_max_is_all_ones() {
let max_uuid = UUID::max();
let expected_bytes = [0xFFu8; UUID_BYTES];
assert_eq!(
max_uuid.bytes, expected_bytes,
"The bytes of a max UUID should all be 0xFF"
);
}
#[test]
fn test_max_is_deterministic() {
let max1 = UUID::max();
let max2 = UUID::max();
assert_eq!(max1, max2, "Two max UUIDs should be equal");
}
#[test]
fn test_max_can_be_used_in_const_context() {
const COMPILE_TIME_MAX: UUID = UUID::max();
const EXPECTED_MAX: UUID = UUID {
bytes: [0xFF; UUID_BYTES],
};
assert_eq!(
COMPILE_TIME_MAX, EXPECTED_MAX,
"A const-evaluated max UUID should match the expected value"
);
match UUID::max() {
COMPILE_TIME_MAX => (),
_ => panic!("A const max UUID should match UUID::max()"),
}
}
}