diff --git a/src/rstd/atomic/array.rs b/src/rstd/atomic/array.rs index 7435f26..33edbfb 100644 --- a/src/rstd/atomic/array.rs +++ b/src/rstd/atomic/array.rs @@ -55,3 +55,29 @@ impl CInliningAtomic for [u8; N] { impl ConstSizeAtomic for [u8; 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 + ); + } +}