erwanvivien / fast_qr

Ultra fast QRCode generation
https://fast-qr.com/
MIT License
208 stars 30 forks source link

Fix #19 #20

Closed AntoniosBarotsis closed 1 year ago

AntoniosBarotsis commented 1 year ago

This fixes #19.

Description

@erwanvivien The issue is here which is called from to_str because command_colors is initialized to an empty vector instead of a vector of 4 Nones

I don't know if the fix makes sense as I didn't look into your code too much but it seems to work and all the tests are passing. Adding to that, it would make sense to check for potential similar issues before merging this. I'm going to be offline for a bit but ai think you should be able to add commits to this, otherwise I'll make an update tonight if needed.

Testing

I added the following to svg.rs to test that the fix worked.

#[cfg(test)]
mod tests {
    use crate::qr::QRBuilder;
    use crate::convert::svg::SvgBuilder;
    #[test]
    fn test() {
        let tmp = SvgBuilder::default();
        let qrcode = QRBuilder::new("https://example.com/")
        .build()
        .unwrap(); 
        tmp.to_str(&qrcode);
    }
}
cargo t -F image,svg -- svg::tests

The test was failing with the same error as mentioned in #19 but it passed after the change I made.

erwanvivien commented 1 year ago

Hello, a command_colors is associated with commands and should always have the same size. So here it unsyncs the command & it's color