a8m / pb

Console progress bar for Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tick() crashes if called before inc()

hfiguiere opened this issue · comments

The following test

    #[test]
    fn tick() {
        let mut pb = ProgressBar::new(100);
        pb.tick();
        assert!(pb.current == 1, "should increment current by 1");
    }

Causes a panic.
I'm not asserting the test is right, but wrong API use should cause a panic

thread 'pb::test::tick' panicked at 'arithmetic operation overflowed', src/pb.rs:303

This is because curr_count is 0 and we try to subtract 1.

Calling pb.inc() as indicated in the documentation make this not crash.

(yes I'm using master)