Bump versions, fix clippy errors
This commit is contained in:
+19
-1
@@ -54,7 +54,7 @@ impl ByteStream {
|
||||
|
||||
let mut data: Vec<u8> = vec![];
|
||||
|
||||
if bit_count % 8 != 0 {
|
||||
if !bit_count.is_multiple_of(8) {
|
||||
let bits_needed = bit_count % 8;
|
||||
data.push(bits[bit_ndx..bit_ndx + bits_needed].load::<u8>());
|
||||
bit_ndx += bits_needed;
|
||||
@@ -148,4 +148,22 @@ mod tests {
|
||||
let new_bytes = bit_stream.get_bytes::<BigEndian>(0, 3).unwrap();
|
||||
assert_eq!(vec![0x02], new_bytes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_bytes_9_bits() {
|
||||
let bytes: Vec<u8> = vec![0xff, 0x80];
|
||||
let bit_stream = ByteStream::from(bytes.clone());
|
||||
|
||||
let new_bytes = bit_stream.get_bytes::<BigEndian>(0, 9).unwrap();
|
||||
assert_eq!(vec![0x01, 0xff], new_bytes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_bytes_9_bits_mid_byte() {
|
||||
let bytes: Vec<u8> = vec![0x0f, 0xf8];
|
||||
let bit_stream = ByteStream::from(bytes.clone());
|
||||
|
||||
let new_bytes = bit_stream.get_bytes::<BigEndian>(4, 9).unwrap();
|
||||
assert_eq!(vec![0x01, 0xff], new_bytes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ use thiserror::Error;
|
||||
pub enum FormatConfigError {
|
||||
#[error("IO error")]
|
||||
IOError(#[from] std::io::Error),
|
||||
#[error("TOML Format Error")]
|
||||
#[error("TOML Format Error in '{file_name}': {err}")]
|
||||
TomlError {
|
||||
file_name: String,
|
||||
err: toml::de::Error,
|
||||
|
||||
Reference in New Issue
Block a user