parent
f77d406983
commit
25ae91f0d2
@ -55,3 +55,29 @@ impl<const N: usize> CInliningAtomic for [u8; N] {
|
|||||||
impl<const N: usize> ConstSizeAtomic for [u8; N] {
|
impl<const N: usize> ConstSizeAtomic for [u8; N] {
|
||||||
const SIZE: usize = N;
|
const SIZE: usize = N;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn cannot_parse_array() {
|
||||||
|
assert_eq!(<[u8; 3]>::parse_slice(&[1, 2, 3]).unwrap(), [1, 2, 3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn cannot_parse_undersized_slice() {
|
||||||
|
assert_eq!(
|
||||||
|
<[u8; 2]>::parse_slice(&[0, 0, 0, 0]).unwrap_err(),
|
||||||
|
ArrayParseError::ExtraData(2),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn cannot_parse_oversized_slice() {
|
||||||
|
assert_eq!(
|
||||||
|
<[u8; 4]>::parse_slice(&[0, 0]).unwrap_err(),
|
||||||
|
ArrayParseError::Eof
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user