Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
terahlunah committed Jul 29, 2024
1 parent ebb53bb commit 214376f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ impl ByteBuffer {
pub fn read_i64(&mut self) -> Result<i64> {
Ok(self.read_u64()? as i64)
}

/// Read a sixteen bytes long value, or return an IO error if not enough bytes are available.
/// _Note_: This method resets the read and write cursor for bitwise reading.
///
Expand Down
2 changes: 1 addition & 1 deletion src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ impl<'a> ByteReader<'a> {
pub fn read_i128(&mut self) -> Result<i128> {
Ok(self.read_u128()? as i128)
}

/// Read a 32 bits floating point value, or return an IO error if not enough bytes are available.
/// _Note_: This method resets the read and write cursor for bitwise reading.
pub fn read_f32(&mut self) -> Result<f32> {
Expand Down
10 changes: 8 additions & 2 deletions tests/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,21 @@ fn test_u64_little_endian() {
fn test_u128() {
let mut buffer = ByteBuffer::new();
buffer.write_u128(0xF0E1D2C3B4A59687F7E6D5C4B3A29180);
assert_eq!(buffer.read_u128().unwrap(), 0xF0E1D2C3B4A59687F7E6D5C4B3A29180);
assert_eq!(
buffer.read_u128().unwrap(),
0xF0E1D2C3B4A59687F7E6D5C4B3A29180
);
}

#[test]
fn test_u128_little_endian() {
let mut buffer = ByteBuffer::new();
buffer.set_endian(Endian::LittleEndian);
buffer.write_u128(0xF0E1D2C3B4A59687F7E6D5C4B3A29180);
assert_eq!(buffer.read_u128().unwrap(), 0xF0E1D2C3B4A59687F7E6D5C4B3A29180);
assert_eq!(
buffer.read_u128().unwrap(),
0xF0E1D2C3B4A59687F7E6D5C4B3A29180
);
}

#[test]
Expand Down
10 changes: 8 additions & 2 deletions tests/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ fn test_u128() {
let mut buffer = ByteBuffer::new();
buffer.write_u128(0xF0E1D2C3B4A59687F7E6D5C4B3A29180);
let mut reader = ByteReader::from(buffer.as_bytes());
assert_eq!(reader.read_u128().unwrap(), 0xF0E1D2C3B4A59687F7E6D5C4B3A29180);
assert_eq!(
reader.read_u128().unwrap(),
0xF0E1D2C3B4A59687F7E6D5C4B3A29180
);
}

#[test]
Expand All @@ -149,7 +152,10 @@ fn test_u128_little_endian() {
buffer.write_u128(0xF0E1D2C3B4A59687F7E6D5C4B3A29180);
let mut reader = ByteReader::from(buffer.as_bytes());
reader.set_endian(Endian::LittleEndian);
assert_eq!(reader.read_u128().unwrap(), 0xF0E1D2C3B4A59687F7E6D5C4B3A29180);
assert_eq!(
reader.read_u128().unwrap(),
0xF0E1D2C3B4A59687F7E6D5C4B3A29180
);
}

#[test]
Expand Down

0 comments on commit 214376f

Please sign in to comment.