Closed michael-yxchen closed 1 year ago
The variable high is off. It should be shifted by (size + offset) instead.
high
(size + offset)
Test to reproduce the error
#[test] fn test_high_bits() { let mut bits = Bits::new(320); assert_eq!(bits.len(), 320); assert_eq!(bits.get_uint(290, 5), 0); bits.set_uint(290, 5, 31); assert_eq!(bits.get_uint(290, 5), 31); bits.set_uint(290, 5, 21); assert_eq!(bits.get_uint(290, 5), 21); // line 84 }
Test error
---- bits::test::test_high_bits stdout ---- thread 'bits::test::test_high_bits' panicked at src/bits.rs:84:9: assertion `left == right` failed left: 29 right: 21
I'm planning to fix the issue myself. Any help reviewing is greatly appreciated!
The variable
high
is off. It should be shifted by(size + offset)
instead.Test to reproduce the error
Test error
I'm planning to fix the issue myself. Any help reviewing is greatly appreciated!