pipecircuit-cli 0.0.2

Command-line architectural tools for Pipecircuit programs
use super::*;
use core::num::NonZeroU64;

#[test]
fn reading_preserves_the_initial_count() {
    let mut counter = Counter::new(Count::new(37));
    assert_eq!(counter.step(Read), Count::new(37));
    assert_eq!(counter.step(Read), Count::new(37));
}

#[test]
fn addition_reports_both_states_and_overflow_preserves_authority() {
    let mut counter = Counter::new(Count::new(18_446_744_073_709_551_614));
    let amount = Amount::new(NonZeroU64::MIN);
    assert_eq!(
        counter.step(Add { amount }),
        AddOutcome::Added {
            before: Count::new(18_446_744_073_709_551_614),
            after: Count::new(u64::MAX),
        }
    );
    assert_eq!(
        counter.step(Add { amount }),
        AddOutcome::Overflow {
            current: Count::new(u64::MAX),
            requested: amount,
        }
    );
    assert_eq!(counter.step(Read), Count::new(u64::MAX));
}