Skip to main content

budgeted/
budgeted.rs

1use std::num::NonZeroUsize;
2
3use fixture3_ddmin::{
4    DdminGuarantee, DdminInput, DdminOptions, DdminStopReason, OracleOutcome, ddmin,
5};
6
7fn main() {
8    let options = DdminOptions::new(NonZeroUsize::MIN, Some(1));
9    let input = DdminInput::new(vec![1_u8, 2, 3, 4], options);
10    let mut oracle = |remaining: &[u8]| {
11        if remaining.contains(&2) {
12            OracleOutcome::Interesting
13        } else {
14            OracleOutcome::NotInteresting
15        }
16    };
17
18    let output = ddmin(input, &mut oracle);
19    assert_eq!(
20        output.guarantee(),
21        DdminGuarantee::Incomplete(DdminStopReason::MaxOracleCallsReached),
22        "DDMin should report an incomplete guarantee when the oracle-call budget is exhausted"
23    );
24    assert_eq!(output.stats().oracle_calls(), 1, "DDMin should stop at the configured budget");
25}