use crate::BitBuf;

#[test]
fn read_u8_be_aligned_full_at_unchecked() {
  let bb = BitBuf::from([0u8, 1, 2, 3, 255, 128, 127]);

  unsafe {
    assert_eq!(bb.read_u8_be_aligned_full_at_unchecked(0), 0);
    assert_eq!(bb.read_u8_be_aligned_full_at_unchecked(1), 1);
    assert_eq!(bb.read_u8_be_aligned_full_at_unchecked(2), 2);
    assert_eq!(bb.read_u8_be_aligned_full_at_unchecked(3), 3);
    assert_eq!(bb.read_u8_be_aligned_full_at_unchecked(4), 255);
    assert_eq!(bb.read_u8_be_aligned_full_at_unchecked(5), 128);
    assert_eq!(bb.read_u8_be_aligned_full_at_unchecked(6), 127);
  }
}

#[test]
fn write_u8_be_aligned_full_at_unchecked() {
  let mut data = [0u8; 3];

  let mut bb = BitBuf::from(&mut data);

  unsafe {
    bb.write_u8_be_aligned_full_at_unchecked(0, 0);
    bb.write_u8_be_aligned_full_at_unchecked(1, 10);
    bb.write_u8_be_aligned_full_at_unchecked(2, 255);
  }

  assert_eq!(data[0], 0);
  assert_eq!(data[1], 10);
  assert_eq!(data[2], 255);
}
