Skip to content

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
read_reg test should read bytes as little-endian
  • Loading branch information
ccostes authored Aug 31, 2024
2 parents 2df9aa6 + a80d68a commit 6faaff5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/device/device_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ fn test_read_reg_u16() {
let block = BLOCK_SYS;
let index_expected = BLOCK_SYS << 8;
let addr = GPO;
let data_expected = u16::to_be_bytes(0x123);
// Bytes are read as little-endian
let data_expected = u16::to_le_bytes(0x123);

let mut mock_handle = MockDeviceHandle::new();
mock_handle
Expand All @@ -64,7 +65,7 @@ fn test_read_reg_u16() {
handle: mock_handle,
};
let result = device.read_reg(block, addr, 2).unwrap();
assert_eq!(u16::from_be_bytes(data_expected), result);
assert_eq!(u16::from_le_bytes(data_expected), result);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/tuners/r820t.rs
Original file line number Diff line number Diff line change
Expand Up @@ -981,8 +981,8 @@ impl R820T {

/// Read register data from local cache
/// # Panics
/// * reg < RW_REG_START
/// * reg > NUM_REGS
/// * If `reg` is less than `RW_REG_START`
/// * If `reg` is greater than `NUM_REGS`
fn read_cache_reg(&self, reg: usize) -> u8 {
assert!(reg >= RW_REG_START); // is assert the best thing to use here?
let index = reg - RW_REG_START;
Expand Down

0 comments on commit 6faaff5

Please sign in to comment.