diff --git a/packages/storage-plus/src/keys.rs b/packages/storage-plus/src/keys.rs index 4566cddab..1fd70a669 100644 --- a/packages/storage-plus/src/keys.rs +++ b/packages/storage-plus/src/keys.rs @@ -598,6 +598,45 @@ mod test { ); } + #[test] + fn naked_8byte_prefixes() { + let pair: (u8, &[u8]) = (123, b"random"); + let one: Vec = vec![123]; + let two: Vec = b"random".to_vec(); + assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); + + let pair: (i8, &[u8]) = (123, b"random"); + let one: Vec = vec![123]; + let two: Vec = b"random".to_vec(); + assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); + } + + #[test] + fn naked_16byte_prefixes() { + let pair: (u16, &[u8]) = (12345, b"random"); + let one: Vec = vec![48, 57]; + let two: Vec = b"random".to_vec(); + assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); + + let pair: (i16, &[u8]) = (12345, b"random"); + let one: Vec = vec![48, 57]; + let two: Vec = b"random".to_vec(); + assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); + } + + #[test] + fn naked_64byte_prefixes() { + let pair: (u64, &[u8]) = (12345, b"random"); + let one: Vec = vec![0, 0, 0, 0, 0, 0, 48, 57]; + let two: Vec = b"random".to_vec(); + assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); + + let pair: (i64, &[u8]) = (12345, b"random"); + let one: Vec = vec![0, 0, 0, 0, 0, 0, 48, 57]; + let two: Vec = b"random".to_vec(); + assert_eq!(pair.prefix(), vec![one.as_slice(), two.as_slice()]); + } + #[test] fn naked_proper_prefixes() { let pair: (u32, &[u8]) = (12345, b"random");