1use crate::{UUID, UUID_BYTES};
2
3impl UUID {
4 #[must_use]
5 pub const fn max() -> Self {
6 Self {
7 bytes: [0xFF; UUID_BYTES],
8 }
9 }
10}
11
12#[cfg(test)]
13mod tests {
14 use crate::{UUID, UUID_BYTES};
15
16 #[test]
19 fn test_max_is_all_ones() {
20 let max_uuid = UUID::max();
21 let expected_bytes = [0xFFu8; UUID_BYTES];
22 assert_eq!(
23 max_uuid.bytes, expected_bytes,
24 "The bytes of a max UUID should all be 0xFF"
25 );
26 }
27
28 #[test]
31 fn test_max_is_deterministic() {
32 let max1 = UUID::max();
33 let max2 = UUID::max();
34 assert_eq!(max1, max2, "Two max UUIDs should be equal");
35 }
36
37 #[test]
41 fn test_max_can_be_used_in_const_context() {
42 const COMPILE_TIME_MAX: UUID = UUID::max();
43 const EXPECTED_MAX: UUID = UUID {
44 bytes: [0xFF; UUID_BYTES],
45 };
46 assert_eq!(
47 COMPILE_TIME_MAX, EXPECTED_MAX,
48 "A const-evaluated max UUID should match the expected value"
49 );
50 match UUID::max() {
51 COMPILE_TIME_MAX => (),
52 _ => panic!("A const max UUID should match UUID::max()"),
53 }
54 }
55}