Skip to content

Commit

Permalink
Fix flaky TryFromBytes tests (#1917)
Browse files Browse the repository at this point in the history
These tests depend on `src` being aligned to multiples of 2. With
this commit, that dependency is explicitly enforced.
  • Loading branch information
jswrenn authored Oct 15, 2024
1 parent 49749b7 commit f04c344
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1960,7 +1960,7 @@ pub unsafe trait TryFromBytes {
/// trailing_dst: [()],
/// }
///
/// let src = &[85, 85][..];
/// let src = 0xCAFEu16.as_bytes();
/// let zsty = ZSTy::try_ref_from_bytes_with_elems(src, 42).unwrap();
/// assert_eq!(zsty.trailing_dst.len(), 42);
/// ```
Expand Down Expand Up @@ -2067,7 +2067,7 @@ pub unsafe trait TryFromBytes {
/// trailing_dst: [()],
/// }
///
/// let src = &[85, 85][..];
/// let src = 0xCAFEu16.as_bytes();
/// let (zsty, _) = ZSTy::try_ref_from_prefix_with_elems(src, 42).unwrap();
/// assert_eq!(zsty.trailing_dst.len(), 42);
/// ```
Expand Down Expand Up @@ -2156,7 +2156,7 @@ pub unsafe trait TryFromBytes {
/// trailing_dst: [()],
/// }
///
/// let src = &[85, 85][..];
/// let src = 0xCAFEu16.as_bytes();
/// let (_, zsty) = ZSTy::try_ref_from_suffix_with_elems(src, 42).unwrap();
/// assert_eq!(zsty.trailing_dst.len(), 42);
/// ```
Expand Down Expand Up @@ -2246,7 +2246,8 @@ pub unsafe trait TryFromBytes {
/// trailing_dst: [()],
/// }
///
/// let src = &mut [85, 85][..];
/// let mut src = 0xCAFEu16;
/// let src = src.as_mut_bytes();
/// let zsty = ZSTy::try_mut_from_bytes_with_elems(src, 42).unwrap();
/// assert_eq!(zsty.trailing_dst.len(), 42);
/// ```
Expand Down Expand Up @@ -2358,7 +2359,8 @@ pub unsafe trait TryFromBytes {
/// trailing_dst: [()],
/// }
///
/// let src = &mut [85, 85][..];
/// let mut src = 0xCAFEu16;
/// let src = src.as_mut_bytes();
/// let (zsty, _) = ZSTy::try_mut_from_prefix_with_elems(src, 42).unwrap();
/// assert_eq!(zsty.trailing_dst.len(), 42);
/// ```
Expand Down Expand Up @@ -2452,7 +2454,8 @@ pub unsafe trait TryFromBytes {
/// trailing_dst: [()],
/// }
///
/// let src = &mut [85, 85][..];
/// let mut src = 0xCAFEu16;
/// let src = src.as_mut_bytes();
/// let (_, zsty) = ZSTy::try_mut_from_suffix_with_elems(src, 42).unwrap();
/// assert_eq!(zsty.trailing_dst.len(), 42);
/// ```
Expand Down

0 comments on commit f04c344

Please sign in to comment.