use super::Quota;
#[test]
fn quota_consumes_single_tokens_until_empty() {
    let quota = Quota::with_initial_tokens(10);

    let mut results = vec![];
    for _ in 0..100 {
        results.push(quota.consume(1));
    }

    assert_eq!(results.iter().filter(|r| r.is_ok()).count(), 10);
    assert_eq!(results.iter().filter(|r| r.is_err()).count(), 90);
}

#[test]
fn quota_consumes_multiple_tokens_until_empty() {
    let quota = Quota::with_initial_tokens(20);

    let mut results = vec![];
    for _ in 0..100 {
        results.push(quota.consume(5));
    }

    assert_eq!(results.iter().filter(|r| r.is_ok()).count(), 4);
    assert_eq!(results.iter().filter(|r| r.is_err()).count(), 96);
}
