Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tick() crashes if called before inc() #11

Closed
hfiguiere opened this issue May 15, 2016 · 1 comment
Closed

tick() crashes if called before inc() #11

hfiguiere opened this issue May 15, 2016 · 1 comment

Comments

@hfiguiere
Copy link

hfiguiere commented May 15, 2016

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.

@hfiguiere
Copy link
Author

(yes I'm using master)

hfiguiere added a commit to hfiguiere/pb that referenced this issue May 15, 2016
a8m added a commit that referenced this issue May 15, 2016
a8m added a commit that referenced this issue May 15, 2016
a8m added a commit that referenced this issue May 17, 2016
@a8m a8m closed this as completed May 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants