bitmaps icon indicating copy to clipboard operation
bitmaps copied to clipboard

Bug with Len: random padding bits are taken into account

Open damv opened this issue 1 year ago • 0 comments

Thanks for the crate, I found out that really counter intuitive behavior:

use bitmaps::Bitmap;

#[cfg(test)]
mod tests {
    #[test]
    fn bitmap_len() {
        let mut a = Bitmap::<10>::new();
        assert_eq!(a.len(), 0);
        a.invert();
        assert_eq!(a.len(), 10); // Assertion `left == right` failed left: 16 right: 10
    }
}

len() function takes into account the 6 padding bits.

My understanding was that the library abstracted the padding bits so only the size requested by the user has an importance (as the example in the README suggests). If I understood well the intention, then it is a bug.

damv avatar Oct 01 '24 21:10 damv