array tests
All checks were successful
buildbot/runtests Build done.

This commit is contained in:
AF 2023-08-04 23:46:02 +00:00
parent f77d406983
commit 25ae91f0d2

View File

@ -55,3 +55,29 @@ impl<const N: usize> CInliningAtomic for [u8; N] {
impl<const N: usize> 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
);
}
}