jcs-elpa / flx-rs

flx in Rust using dynamic module
GNU General Public License v3.0
22 stars 8 forks source link

Overflow on longer strings #1

Closed arminfriedl closed 3 years ago

arminfriedl commented 3 years ago

Rust panics with thread 'test_nok' panicked at 'attempt to multiply with overflow', src/search.rs:256:40 on longer strings. Maybe somewhat surprisingly, both the query as well as the search string seem to contribute to this panic.

#[test]
fn test_ok() {// base, works
    let s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
    score(s, "ABCDE");
}

#[test]
fn test_ok2() {// s increased by one, query reduced by one, still works
    let s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890A";
    score(s, "ABCD");
}

#[test]
fn test_panic() {// s increased by one, query left as is, panics
    let s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890A";
    score(s, "ABCDE");
}

I'm not sure whether only short strings are supported or this is a legit bug.

arminfriedl commented 3 years ago

Wrong repository, moved to https://github.com/jcs090218/flx-rs/issues/2#issue-1047939300